'KMM ios flow.combine throwing no event loop error
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.
Solution 1:[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")
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | RĂ³bert Nagy |