Are JsValue.Call
and JsValue.Invoke
meant to keep/change scoped variables?
#1388
Unanswered
scarletquasar
asked this question in
Q&A
Replies: 1 comment 2 replies
-
This test case passes as green so I guess it works? [Fact]
public void TestScopedAccess()
{
var engine = new Engine();
engine.Execute(@"function scopedBlock() {
let a = 1;
const b = () => a = 2;
_callSomeBindingWithInvoke(b);
return a;
}");
engine.SetValue("_callSomeBindingWithInvoke", new Action<JsValue>(value =>
{
value.Invoke(_engine);
}));
var result = engine.Evaluate("scopedBlock()");
Assert.Equal(2, result);
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Supposing I make that code:
And the
_callSomeBindingWithInvoke
code behind is:What is the supposed value of
a
after the function return? Currently, Its not keeping the scope (on my usage) but I want to know if that is the objective. Same forCall()
.Beta Was this translation helpful? Give feedback.
All reactions