Is it possible to know all the status of a coroutine Job ?
I find this function extension but I can't access to all the status of a Job
:
fun Job.status(): String = when {
isCancelled -> "cancelled"
isActive -> "Active"
isCompleted -> "Complete"
else -> "Nothing"
}
There is no isNew
, isCancelling
or isWaitingForChildren
functions with the Job
classe. Why ?
Thanks to Drawn Roccoon I found the solution :
fun Job.status(): String = when {
isActive -> "Active/Completing"
isCompleted && isCancelled -> "Cancelled"
isCancelled -> "Cancelling"
isCompleted -> "Completed"
else -> "New"
}
More information in this link : https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-job/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With