In Kotlin 1.3.11 and v1.0.1 of kotlinx-coroutines-reactive
, I've found that when a Publisher<Publisher<T>>
completes before consumeEach
is called on some of its inner Publishers, these inner Publishers don't execute at all when they are eventually started. Is this expected? Consider for example:
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 {}`
}
Which results in
outer finished
try to start inner
Process finished with exit code 0
Is my gut on the right track that this has something to do with ProducerScope
s (since Publisher
is scoped by these, cf. docs)?