7

Is it possible to launch any coroutines when targeting JavaScript? It doesn't like any of the usual ways like async{}

Example on: https://github.com/thigg/no-kotlinx-in-js

1 Answer 1

6

Yes, you can. Take a look at example-frontend-js — frontend application written in Kotlin/JS that uses coroutines to implement animations in imperative style.

Don't forget to add a dependency on org.jetbrains.kotlinx:kotlinx-coroutines-core in your Gradle configs.

Sign up to request clarification or add additional context in comments.

7 Comments

Im on Kotlin 1.3.41. I created a Kotlin JS Project with intellij idea and it says there is no package import kotlinx.coroutines.*. Did I get any config wrong?
Can't spot differences so far, they seem simply to include the stdlib, nothing else. I'm doing the same as far as I can see. I will build a minimal failing example...
I created a minimal-not-working-example: github.com/thigg/no-kotlinx-in-js maybe you can help me to spot what I am doing wrong?
You don't have all the dependencies they have in a sample project. Take a look at parent's build.gradle: github.com/Kotlin/kotlinx.coroutines/blob/master/…. That allprojects configure additional dependencies and plugins.
Yes, it was the missing import. Thanks. Will you update your answer?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.