kotlin-coroutines-flow

How do you split a 'hot' stream of events from a callback in Kotlin?

那年仲夏 提交于 2020-05-31 04:58:28
问题 I'm processing a hot stream of events, arriving by callback. 'Downstream' I'd like to split it into multiple streams, and process them.The events all arrive sequentially from a single thread (which I don't control, so I don't think I can use co routines here) What is the right structure to use here? I can create a Flow pretty easily, using callbackFlow and sendBlocking, but the semantics don't seem to line up, as the Flow isn't cold. What is the best way to split a flow into multiple