Is intermediate flow operators are cancellable? Are they cancelled when the calling scope is cancelled? For instance:
Copy code
// If the collecting scope is cancelled before this map operation,
// seems like map operation is not cancelled and throws an exception
numbersFlow.map {
// There is an operation which throws exception
}
.flowOn(<http://Dispatchers.IO|Dispatchers.IO>)
I have to use
ensureActive()
before mapping but is it the expected behaviour?
fatih
05/16/2020, 4:54 PM
I can also use
catch
but just curious why it is not cancelled itself since the calling scope is cancelled
fatih
05/16/2020, 6:08 PM
Ok. Intermediate operators are not suspend functions and this is why they are not cancellable like normal coroutine suspend functions. They are in deed normal functions. So