Closed MoonRune closed 3 years ago
Plugin wraps the parameters and returns automatically. Both your demo returns Future
in the function, and you would get Promise
in Javascript side. you can get result with await IN JAVASCRIPT:
(async (url) => {
var rsp = await http(url);
/** or **/
http(url).then((rsp) => {
/** your code here **/
})
})()
If you want to get the return value directly. you SHOULD NOT use async syntax or return Future in the function:
await setToGlobalObject.invoke(["http", (String url) {
return "directly";
}]);
thanks. i want my js code run after dart future task done. it should be related with dart microtask .
in my demo, it return future instead of future.
event i change the code to:
await setToGlobalObject.invoke(["http", (String url) async {
return (await Dio().get(url)).toString();
}]);
is there any way to get reusult?