-
-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handling a JS function that returns a Promise #941
Comments
What function do you mean? There aren't functions in Java, there are methods only
I don't have enough information about your code base and can't judge, but perhaps you are trying to run async code from within JavaScript event handler, which is prohibited. One possible workaround is start a new |
Yes, I mean the
Hmm. All I'm trying to do is someway be able to give Java, a value, from JavaScript, immediately. Thanks Edit: By immediate I mean, Java needs to immediately consume a value that should be provided from JavaScript. |
It's supported in TeaVM: https://teavm.org/jcl-report/recent/classes/java.lang.Thread.html
There's no way to do something "immediately" with a promise. Promise only resolves eventually, and you can't influence that. Anyway, I'll try to clarify. Your button.onClick(e -> {
doSomething();
}); you need following: button.onClick(e -> {
var thread = new Thread(() -> doSomething());
thread.start();
}); |
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:My JS side code:
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.
The text was updated successfully, but these errors were encountered: