When using callBackflow, what's the correct way of...
# coroutines
h
When using callBackflow, what's the correct way of cancellation? 1. Do you close the channel and pass it the exception? 2. Do you cancel the scope and provide a CancellationException?
e
Depends on the reason (initiator) of cancellation. The data source would close the channel when the data is over. The data consumer would cancel its scope when it does not want more data.
If you are writing a data producer then you close the channel with your exception.
h
Thanks for the clarification