What actually cancels a Flow? The act of stopping ...
# coroutines
f
What actually cancels a Flow? The act of stopping to collect it?
m
afaik a Flow ends if either • the Flow is complete (no more elements, or exception thrown - e.g. when canceled). • the Flow collector has thrown an exception - e.g. when cancelled.
takeWhile
and alike throw a
CancellationException
internally
f
thank you
so when I collect in a coroutine scope and that scope is cancelled, the Flow is definitely cancelled
m
Yes, same with
launchIn(scope)
f
thank you