Hi, is there any way to use `runBlocking` with K/N...
# coroutines
k
Hi, is there any way to use
runBlocking
with K/N? I used it in my MPP project for synchronous API and works fine on Android but on iOS it never returns. Even very simple example like this:
Copy code
val result = runBlocking(MainDispatcher) {
            return@runBlocking "yes"
        }
I found issue which is kinda related but there is no answer: https://github.com/Kotlin/kotlinx.coroutines/issues/952
l
Just use
runBlocking
without specifying a dispatcher.
It'll use the thread being blocked as an event loop. Beware, waiting for callbacks on that same thread will result in a deadlock.
Maybe you just need to use
launch
with the dispatcher from this comment? https://github.com/Kotlin/kotlinx.coroutines/issues/470#issuecomment-440080970