konsoletyper / teavm-site

Sources of TeaVM website
http://teavm.org
MIT License
5 stars 24 forks source link

Coroutines example (foo) does not work / is not reproducable #32

Open JakWai01 opened 3 years ago

JakWai01 commented 3 years ago

As written in the title, the foo example does not work. To get it working, we would need the JsConsumer class. The JsConsumer class of the "org.teavm.html4j.*" package can't be used though and this is the only appereance of the JsConsumer class I can find in the repo.

Thanks for your work!

konsoletyper commented 3 years ago

This example is not intended to just be blindly copy-pasted. It's just an outline of the code that uses @Async annotation and it does not describe how foo function looks like and what is JsConsumer (I believe, you should declare them according to your needs). This example just shows that you need two things to use @Async annotation:

Optionally, the second method may use JSO API to call native JavaScript function (it's primary use case for @Async annotation). Instead these verbose and unclear explanations I decided just to show some abstract code.

If you want some real examples of @Async annotation, you can clone TeaVM or TeaVM Flavour repository and search for usages of @Async annotations.