0
 suspend fun heyStackOverFlow(): Int {
    val flow1 = flow<Int> { 1 }
    val flow2 = flow<Int> { 2 }
    return flow1.combine(flow2) { f1, f2 -> f1 + f2 }.single()
}

I use this in build.gradle

sourceSets {
    val commonMain by getting {
        dependencies {
            implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2-native-mt")
            ...
        }
    }

I get this error

 kotlin.IllegalStateException: There is no event loop. Use runBlocking { ... } to start one.

I've tried playing around with actual / expected dispatchers from other questions but no success. On android this works perfectly, on ios it doesn't.

General Grievance
  • 4,555
  • 31
  • 31
  • 45
Boldijar Paul
  • 5,405
  • 9
  • 46
  • 94
  • Does this answer your question? [KMM on iOS: There is no event loop. Use runBlocking { ... } to start one](https://stackoverflow.com/questions/66917563/kmm-on-ios-there-is-no-event-loop-use-runblocking-to-start-one) – Phil Dukhov Dec 08 '21 at 13:04
  • I updated my answer in the linked question with more details from the documentation, which should help you – Phil Dukhov Dec 08 '21 at 13:04

1 Answers1

1

You could check gradle dependencies as some 3rd party might be pulling in a non native-mt version of coroutines.

If that's the case you can force using the native-mt version as suggested by Philip:

version {
    strictly("1.5.2-native-mt")
}
Róbert Nagy
  • 6,720
  • 26
  • 45