teavm
teavm copied to clipboard
Handling a JS function that returns a Promise
Hello, thanks again for TeaVM.
From past few hours, I'm trying to figure out a situation where my Java program immediately expects a value (from the JS).
I learnt that TeaVM dosent support sleep()
function. I did what I can after looking into the docs, such as:
@Async
public static native String stdInput();
private static void stdInput(AsyncCallback<String> callback) {
stdInputAsync(callback::complete);
}
...
@SuppressWarnings("unused")
@JSFunctor
interface ICallback extends JSObject {
void complete(String result);
}
My JS side code:
function stdInput(callback: (result: string) => void): void {
callback("meow");
}
But it results in this error:
If I simply try to return a promise in stdInput()
, I get an empty String at the Java side.
Please help.