How can I close a channel from which I am receivin...
# coroutines
k
How can I close a channel from which I am receiving values in a coroutine/suspend func as response to canceling the coroutine?
k
Not exactly but close. I want to close the channel when canceling the coroutine that has the channel inside because after the channel closes the procuder that sends items to my channel and is checking for the closed state will stop. The producers is another channel that I got from an Rx api so it will close it’s subscription
e
Use
produce
coroutines builder, which binds channel & coroutine lifecycle for you
k
Ok I will try this out. If I have a
use
block on
SubscriptionReceiveChannel
will it run after the I cancel the producer an the Cancellationexcpetion will be thrown?
e
Yes
👍 1
k
Thank you very much