So I gave a talk about Kotlin/Native and I was und...
# coroutines
So I gave a talk about Kotlin/Native and I was under the impression that there was no
on K/N because I could never successfully get it to import. But @russhwolf pointed out that it is definitely there. I looked in my local
and lo and behold, there it is. What am I missing about getting it to import in a
Relevant bit of `build.gradle`:
Copy code
commonMain.dependencies {
            api "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
            implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$coroutines_version"
            implementation "io.ktor:ktor-client:$ktor_version"
            implementation "io.ktor:ktor-client-core:$ktor_version"
            implementation "io.ktor:ktor-client-json:$ktor_version"
            implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serialization_version"

        commonTest.dependencies {
            implementation "org.jetbrains.kotlin:kotlin-test-common:$kotlin_version"
            implementation "org.jetbrains.kotlin:kotlin-test-annotations-common:$kotlin_version"
It's not in common in the stdlib kotlinx, just jvm and native. So you need to add your own `expect`/`actual` declarations to link them.
It's not present in js target, hence it's not present in multiplatform. Use your own multiplatform declaration.
gooooot it.
will mess with it and see what i can figure out
You do something like this in common
expect fun <T> runBlocking(context: CoroutineContext = EmptyCoroutineContext, block: suspend CoroutineScope.() -> T): T
And then something like this in JVM/Native
actual fun <T> runBlocking(context: CoroutineContext, block: suspend CoroutineScope.() -> T): T = kotlinx.coroutines.runBlocking(context, block)
See also the workaround posted in which further includes a js implementation wrapping around a Promise
(essentially the same in AndroidTest). Thanks @russhwolf for correcting my misunderstanding!
­čĹŹ 1