在 kotlinx-coroutines-reactive
的Kotlin 1.3.11和v1.0.1中,我发现当 Publisher<Publisher<T>>
在某些内部发布者上调用 consumeEach
之前完成时,这些内部发布者在最终启动时根本不执行 . 这是预期的吗?考虑例如:
publish {
send(publish<Unit> {
// delay(1E6); // optionally try to wait a long time to verify it's not run at all
println("inner finished")
})
// send(launch { println("inner finished") }) // note: this isn't a problem for launch
println("outer finished")
}
.consumeEach {
yield()
println("try to start inner")
it.consumeEach { }
// it.join() // try this when sending `launch {}`
}
结果如何
outer finished
try to start inner
Process finished with exit code 0
我的直觉是否与 ProducerScope
s有关(因为 Publisher
的范围是这些,参见docs)?