Can anyone help me understand the use case difference for a
callbackFlow
and a
Channel
? both seem to support "hot" streams
l
louiscad
11/18/2020, 3:45 AM
The former has the latter, but it's auto-closed on cancellation of the flow collector.
louiscad
11/18/2020, 3:46 AM
As explained in their respective docs in more details.
z
Zach Klippenstein (he/him) [MOD]
11/18/2020, 4:48 AM
Channel is a synchronization primitive for communicating between coroutines. CallbackFlow is basically just shorthand for creating a channel, then launching a coroutine to send to the channel, and returning a Flow that reads from the channel.