【发布时间】:2022-01-13 09:25:39
【问题描述】:
suspend fun heyStackOverFlow(): Int {
val flow1 = flow<Int> { 1 }
val flow2 = flow<Int> { 2 }
return flow1.combine(flow2) { f1, f2 -> f1 + f2 }.single()
}
我在 build.gradle 中使用它
sourceSets {
val commonMain by getting {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2-native-mt")
...
}
}
我收到此错误
kotlin.IllegalStateException: There is no event loop. Use runBlocking { ... } to start one.
我尝试与其他问题的实际/预期调度员一起玩,但没有成功。 在 android 上完美运行,在 ios 上却不行。
【问题讨论】:
-
我用文档中的更多详细信息更新了链接问题中的答案,这应该会对您有所帮助
标签: ios flow kotlin-multiplatform kmm