What are use cases for the `.cancellable()` flow o...
# coroutines
l
What are use cases for the
.cancellable()
flow operator?
c
I actually have seen this operator before, but upon reading its documentation, my first thought is to help ensure the Flow doesn’t continue processing emissions if the code inside
collect { }
doesn’t make any suspending function calls. This is probably a very rare situation, so isn’t something you’d really need to worry about if you’re just getting started with Flows. Normally, everything in the core coroutines library checks for cancellation automatically, but if you are doing something that emits values and nowhere in the Flow’s chain do any methods from the core coroutines get called, this operator will step in an check for cancellation so you don’t have to manually.