Flow question: What is recommended way to get a f...
# coroutines
p
Flow question: What is recommended way to get a flow of tap events. In android we give views a callback for these events. This is where many devs will try to get started with flows, yet is unclear how to do so. Is best way to use flowViaChannel with a callback that does channel.offer()? Any thoughts on this?
z
Generally yes, that is how you bridge callback code to Flow code. Although note that
flowViaChannel
has been deprecated in favor of
channelFlow
.
Although if the listener you’re registering is a
setFoo
instead of
addFoo
, you might need to multicast. You could use a
BroadcastChannel
or David Karnok’s new library: https://github.com/akarnokd/kotlin-flow-extensions