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

eygraber

07/15/2021, 6:23 AM
If I'm in a
callbackFlow
what's the best way to determine if I should still emit?
isActive
or
!isClosedForSend
(or both)?
b

bezrukov

07/15/2021, 8:32 AM
just remove your callback in
awaitClose { }
. With new channel api (coroutines 1.5+) it's safe to call `trySend`/`trySendBlocking` anyway.
e

eygraber

07/16/2021, 7:19 PM
I think I've encountered race conditions in the past where my listener was still invoked (maybe a concurrent invocation with
awaitClose
firing or something like that), although I'm not 100% sure I didn't start doing this following the pattern that I use with
suspendCancellableCoroutine
3 Views