it still seems unclear whether to use `callbackFlo...
# coroutines
z
it still seems unclear whether to use
callbackFlow
vs
channelFlow
. It seems the latter respects operator fusion, but the prior does not?
d
One of them will throw an exception if you don't call
awaitClose
.
Only use
callbackFlow
if you're dealing with callbacks. Use
channelFlow
otherwise.
z
So they both respect operator fusion?
d
The only difference between them is the exception throwing.
z
I'm trying to think why I would ever want to use
channelFlow
because my only use case for it is to register/unregister callbacks
d
Some people want to do concurrent
emit
.
👆🏼 1
👆 3
z
Ah, interesting
u
hmm why not just
flow { .. }
? i thought that builder was main selling point of flow
s
Because as soon as the provided lambda to the
flow
call ends/returns, the
Flow
that it returns ends/completes. The callback/channelFlow builders provide a suspending awaitClose method allowing this lambda to suspend indefinitely.
🙏 1