ekibun / flutter_qjs

A quickjs engine for flutter.
https://pub.dev/packages/flutter_qjs
MIT License
146 stars 28 forks source link

support call function name #26

Closed guzishiwo closed 2 years ago

guzishiwo commented 2 years ago

Can support loading js with multiple functions and then calling the specified function name?

final js = """
function a() {}

function b() {}

function c() {}
""";

final jsInvokable = engine.evaluate(js);
jsInvokable.invoke("a", [])
ekibun commented 2 years ago

You can return an object that contains the functions and get from map

final js = """
({
   a: function () {},
   b: function () {},
   c: function () {},
})
""";
final ret = engine.evaluate(js);
ret["a"].invoke([])