public async Task<Boolean> DoSomethingAsync() { ... }
I want to call that from JS and await the result (as I talked with Marc, a Task<T> should be returned as a promise on JS side and the promise resolve callback should get the T as its value parameter).
However the browser tells me that Uncaught TypeError: myCode.DoSomethingAsync(...).then is a not funtion.
So it seems the Task does not really gets translated/wrapped into a JS promise.
I attached a small repro project. Just the code in the MyCode.cs file and the call in the index.html, started by a separate button click.
I could have been mistaken here, last October we shipped
E25397: WebAssembly: await support for JS Promise
which was the issue i was recalling when we spoke, but reading it now, it looks like this is the reverse (using await on a promise). I’ll log an issue/feature request for this one.
This works now. Say you have (Mercury but the same really goes for C#):
Public shared async Function Test() As Task(Of String)
Return "hello"
End Function
Public Async Function Test2() As Task(Of String)
Return "Is it me you are looking for?"
End function
You can do:
result.Program_Test().then(function(b) {
console.log("Tested " + b);
});
var x = program.Test2()
x.then(function(b) {
console.log("Tested " + b);
});
http://127.0.0.1:51802/index.html:14 Tested hello
http://127.0.0.1:51802/index.html:18 Tested Is it me you are looking for?