Is there some (even dumb) implementatio of `runBlo...
# coroutines
p
Is there some (even dumb) implementatio of
runBlocking
for JS? The project I'm working has this:
expect fun <T> runBlocking(context: CoroutineContext = EmptyCoroutineContext, block: suspend CoroutineScope.() -> T): T
I tried someting like:
Copy code
var result: T? = null
val job = GlobalScope.launch { result = block }
while (!job.isCompleted) {}
return result!!
Yeah, I know it has many mistakes, but the main problem is the while loop block the execution of the coroutine.
Js runtime is non-blocking by design. Nodejs just kinda hacks it with their sync io apis