Colton Idle
10/20/2021, 9:09 AMDominaezzz
10/20/2021, 11:12 AMK Merle
10/20/2021, 11:13 AMColton Idle
10/20/2021, 11:30 AMCasey Brooks
10/20/2021, 1:50 PMcallbackFlow
might be a better choice, since it is cold. A SharedFlow
is hot, so is always running, and is ideally meant for when you have multiple subscribers.
An alternative would be to pass the items into a Channel
and then do channel.consumeAsFlow()
. This is useful when you want the items to get put into the channel anytime (not only when there are subscribers), but you only want each item handled once. It can also buffer the items until you actually start collecting from the channel, unlike SharedFlow
which will drop anything emitted to it when there is no subscriber.