Hi, is there a way to cancel/close a `ReceiveChann...
# coroutines
l
Hi, is there a way to cancel/close a
ReceiveChannel
without clearing its buffer? I'd like to stop an underlying items generation, and get what was processed so far as a list. I used
cancel()
in the past, but it seems it now clears the buffer, and I'm looking for an alternative.
e
cancel
- clears. It is used by receiver to indicate that it does not plan to receive anything anymore.
close
- dose not clear. It is used by sender to indicate that it does not plan to send anymore.
l
It makes it a bit hard to receive elements only for a time duration, but I could solve my problem with an
async
block calling
toList()
, then cancelling before awaiting the result of the
async
block. Thank you!