Search code examples
intellij-ideakotlinkotlinx.coroutineskotlin-js-interop

Launch-Coroutine and others not supported for KotlinJS 1.2?


I'm currently trying out coroutines for my kotlin-js project on node.js.

I'm using IntelliJ-Idea and kotlin plugin 1.2.40

Coroutines should be supported, are they? But the "launch"-coroutine is not found by the IDE?!

On the other hand the namespace kotlin.coroutines.experimental is found and i can use for example the suspendCoroutine function but not much else what should actually be available for coroutines.


Solution

  • launch as well as async and all the other stuff you use directly is in kotlinx.coroutines, which is not a part of the standard library. The standard library only contains the low-level primitives like suspendCoroutine that you mention.

    So you must add a dependency to org.jetbrains.kotlinx:kotlinx-coroutines-core.