You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let context = Context::new().unwrap();
context.eval(" class Foo { bar() { return 42; } } function setup() { return new Foo(); } function update(foo) { return foo.bar(); }").unwrap();let foo = context.call_function("setup",vec![JsValue::Undefined]).unwrap();let bar = context.call_function("update",vec![foo]).unwrap();eprintln!("{:?}", bar);
That I would expect to succeed and print 42 but fails with a TypeError: not a functionwhen calling .bar(), as if foo is just a regular object, not a class, in the second .call_function
What I think is the equivelant C version seems to work.
Hmm it seems when you call setup the returned JSValue is actualy serialized to a JSValue::Object which is a HashMap<String, JSValue> and not a pointer to your instance of Foo
You need to call the raw invoke_function api's instead
Hello I have code that looks like the following:
That I would expect to succeed and print
42
but fails with aTypeError: not a function
when calling.bar()
, as iffoo
is just a regular object, not a class, in the second.call_function
What I think is the equivelant C version seems to work.
Am I using the API incorrectly?
C version
The text was updated successfully, but these errors were encountered: