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.
jaqxues
10/06/2020, 9:26 PM
Maybe working solution:
Copy code
channel.broadcast().asFlow()
But how will I unsubscribe a collector (like unregistering a listener)
a
araqnid
10/07/2020, 9:04 AM
Unsubscribe - cancel the scope that the collection is happening in.
j
jaqxues
10/08/2020, 9:02 AM
Yep, ended up using a BroadcastChannel (conflated) and canceling the scopes, thanks!