Hi,
How can I get callback result from Uno.Foundation.WebAssemblyRuntime.InvokeJS ?
for example like Promise in javascript etc...
You need to call back your code from js/ts. We're already doing that for the wasm http handler if you want an example.
https://github.com/nventive/Uno/blob/master/src/Uno.UI.Wasm/ts/HttpClient.ts
Thank you, I don't know ts, but i make this example:
C#
var data = Uno.Foundation.WebAssemblyRuntime.InvokeJS("openFileDialog();");
Console.WriteLine("result: " + data);
and js:
async function openFileDialog() {
function resolveAfter2Seconds(x) {
return new Promise(resolve => {
setTimeout(() => {
resolve(x);
}, 2000);
});
}
var x = await resolveAfter2Seconds(10);
return x;
}
this always show me result "result: [object Promise]" not real data.
Async functions are not supported by InvokeJS, which is synchronous. You need to call a C# method manually at the end like this.
@Ali-YousefiTelori @MatFillion
This feature has been merged into master and available as version 3.0.0-dev.25 on nuget.
Most helpful comment
@Ali-YousefiTelori @MatFillion
This feature has been merged into
masterand available as version3.0.0-dev.25on nuget.