I currently have a listener pattern that just puts...
# coroutines
I currently have a listener pattern that just puts functions in a list and invokes them if a new event occurs can i make this pattern use flows instead? the problems i imagine: * can multiple collectors get the same values? * can i "unsubscribe" collectors? I currently have a channel, so i can dispatch events from somewhere else, flow just did not fit my needs. So channel.receiveAsFlow is what i would want, but that would make it so I can only collect the element once.
Maybe working solution:
Copy code
But how will I unsubscribe a collector (like unregistering a listener)
Unsubscribe - cancel the scope that the collection is happening in.
Yep, ended up using a BroadcastChannel (conflated) and canceling the scopes, thanks!