Hey <@U2E974ELT> or any other helpful friends, I'm...
# multiplatform
m
Hey @elizarov or any other helpful friends, I'm currently messing around with a multi-platform project and I am trying to get coroutines up and running. I have
kotlinx-corountines-core
imported through my common module and I have been successfully using it transitively in the JVM project (a little TornadoFx visualizer) to do a bit of processing off of the main thread. However, I am now trying to speed up some of the common logic and I've just started getting an unresolved reference to
kotlinx
,
runBlocking
and
launch
when compiling the common module. Is there something special I need to do in the Gradle imports to ensure that I am getting an implementation of coroutines that is compatible with Kotlin common? Some other trick that I am missing?
g
kotlinx.coroutines now available only for JVM and cannot be used in common module
But you can write platform specific implementation of suspend function
m
That'd do it, thanks so much for the fast reply. Seems like the right path forward
g
processing off of the main thread
Because for example this is just impossible for JS which is single-thread language
m
Right, makes sense
g
But you can use coroutines in common module, but you need different coroutine builders for different platforms
m
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.coroutines.experimental/index.html So basically, everything that is listed in the 'ALL' dropdown here should be safe to use?
g
Everything in kotlin.coroutines package available for the all platforms, but particular implementation kotlinX.coroutines is jvm.
Actually not all components of kotlinx.coroutines make sense for all platforms, like runBlocking for example for js or any other thread related stuff
m
Got it, was missing the kotlin vs kotlinx subtlety