https://kotlinlang.org logo
#coroutines
Title
# coroutines
s

streetsofboston

02/04/2019, 6:10 PM
I have a
ReceiveChannel
that the caller can use to receive data sent from repeated callback. If something goes wrong, the
Channel
implementing the returned
ReceiveChannel
is closed with a
Throwable
. How can I catch this throwable? I can’t find a method on a
ReceiveChannel
that takes a callback function to handle a side-effect of closing a channel (with or without an error).
e

evan

02/04/2019, 10:45 PM
Can you use a try-catch-finally pattern to route events the way you expect?
s

streetsofboston

02/04/2019, 10:58 PM
Nope, only thing I have is a
ReceiveChannel
and I’d like to intercept any closing of the channel, whether it be with an error or just plain closing.
r

radityagumay

02/05/2019, 2:18 PM
How about checking
isActive
?
s

streetsofboston

02/05/2019, 2:41 PM
Thank you. I can't check or poll (for the
isActive
status). The code needs a callback when the channel is being closed (with or without error).
4 Views