for use cases that involve multiple emitters/listeners for a data stream? From what I've read online, Flow is meant to be a safer alternative to Channel, but seems best used for one to one communication?
t
tseisel
03/24/2020, 6:15 PM
There are 2 kinds of `Flow`s: cold and hot.
Cold flows wait for a consumer to subscribe before emitting, and re-emit the same sequence to each subscriber independently of each other.
Hot flows could start emitting before having any subscriber, and may not send the same sequence to each subscriber. A good example is a flow backed by a callback (click event, etc).
tseisel
03/24/2020, 6:16 PM
There is currently a way to broadcast events emitted by a flow to multiple listeners: the
broadcastIn(CoroutineScope)
operator.
z
zak.taccardi
03/24/2020, 6:27 PM
channels and flows are not mutually exclusive
zak.taccardi
03/24/2020, 6:28 PM
Channels are a synchronization primitive for communicating between coroutines,
Flow<T>
is for exposing an API for asynchronous emissions of