https://kotlinlang.org logo
Title
w

walled

03/11/2018, 11:52 PM
Hey :) Does anybody know if we can use coroutines in native projects yet? Or rather has anyone actually done it before and could point me to some documentation on how to include it?
😎 1
g

gildor

03/12/2018, 1:21 AM
Coroutines already part of the language, no need to include them. But kotlinx.coroutines (library with higher level primitives for coroutines) not available yet for Kotlin/Native. You can check this EchoServer sample that uses coroutines for async socket operations: https://github.com/JetBrains/kotlin-native/blob/master/samples/nonBlockingEchoServer/src/main/kotlin/EchoServer.kt
w

walled

03/12/2018, 1:51 AM
Aah nice! That explains why my compiler recognized the suspend keyword but not the
launch { }
function. Thanks
g

gildor

03/12/2018, 2:02 AM
This is full API of coroutines that available as part of the language http://kotlinlang.org/api/latest/jvm/stdlib/kotlin.coroutines.experimental/index.html All other stuff, like
launch
,
async
,
Channels
etc are just library functions, these particular APIs a part of kotlinX.coroutines library https://github.com/Kotlin/kotlinx.coroutines