Hi! Coroutine + Multiplatform question. I have th...
# coroutines
d
Hi! Coroutine + Multiplatform question. I have this code on Linux, using Kotlin/Native:
Copy code
class MyClass : CoroutineScope by MainScope() {
  fun execute() = launch {
    delay(1000)
    println("finished")
  }
}

fun main() = runBlocking {
  val clazz = MyClass()
  clazz.execute()
}
This throws an exception:
Copy code
kotlin.IllegalStateException: There is no event loop. Use runBlocking { ... } to start one.
What do I do wrong? • If MyClass is external and I can't modify it, how to solve this? • For some reason if I run the code from the
main()
function in Android Activity (which doesn't even have any CouroutineScope), it runs perfectly well. Why?