Does anyone have an elegant way to gracefully stop...
# flow
a
Does anyone have an elegant way to gracefully stop processing a flow, other than cancelling at source? Some sources are not easily cancellable, like (e.g.) StateFlow. I may also have several flows collecting from a StateFlow, but only want to cancel one of them. [Conflated]BroadcastChannel will let me cancel my subscription to it, but there seems no obvious equivalent for flows?
ah - it appears that
takeWhile
is my friend!