abner / flutter_js

A Javascript engine to use with flutter. It uses quickjs on Android and JavascriptCore on IOS
MIT License
463 stars 114 forks source link

Is evaluate() the ONLY WAY of using this library ?? #119

Open momole02 opened 1 year ago

momole02 commented 1 year ago

I have made some researches on the library in the API documentation. I have noticed many UNDOCUMENTED methods which involve

If you can't provide good examples of using your libraries then document them, and if the only thing your library can do is evaluate() it's pretty disappointing.

ekkis commented 4 months ago

I've been researching the interoperability between Flutter and Javascript. it's poor at best, it would seem, and I may have to dump Flutter, sadly abandoning what I've built so far for React Native

liruohrh commented 1 month ago

for QuickJs, I tested it for a long time the interoperability between Flutter and Javascript..

Dart call JS

var jsInvokable = engine.evaluate("greet") as JSInvokable;
jsInvokable.invoke(["XXX"]);
JsRef.freeRecursive(jsInvokable);

Js call Dart

var jsInvokable = engine.evaluate("(key, value)=>this[key]=value") as JSInvokable;
jsInvokable.invoke([
"add",
(a1, a2){
  return a1 + a2;
}
]);
JsRef.freeRecursive(jsInvokable);

Proxy Object