<@U1JP5M6LU> It does not really matter if `Job()` ...
# coroutines
e
@spand It does not really matter if
Job()
had completed “normally” or “was cancelled”. You can tell the difference (between normal completion and cancellation) with
isCancelled
and that is the only difference. Just use
cancel()
in all cases and don’t use
isCancelled
.
g
do you mean don’t use
isCompleted
?
Becausae isCompleted is true for any (cancelled or finished normally coroutine)
e
You should use
isCompleted
. That is how you can tell whether your “lifecycle” has completed or not. You should not use
isCancelled
because the difference between “completed normally” and “cancelled” is quite superfluous.
g
yeah, from point of view of lifecycle, sure, got your point
I think we already had discussion in this channel about “how to detect that coroutine finished without cancellation”
e
I, for one, question the very need to be able to make this distinction. See here: https://github.com/Kotlin/kotlinx.coroutines/issues/220
s
Thanks for the reply. I just expected the lib to have different behavior depending on cancellation/normal completion so I try to keep the code aligned with my intentions.. but if not then great 🙂