Kulwinder Singh
05/16/2019, 11:09 AMcontinuation.isCompleted
i have used this and its working fine, is it ok ? suspend fun <T> Task<T>.await(): T {
return suspendCancellableCoroutine { continuation ->
addOnSuccessListener {
if (continuation.isCompleted.not())
continuation.resume(it)
}.addOnFailureListener {
if (continuation.isCompleted.not())
continuation.resumeWithException(it)
}
}
}
Morten
05/16/2019, 11:40 AMprivate fun <T> CancellableContinuation<T>.resumeOnlyOnce(value: T) {
if(!isCompleted) resume(value)
}
Kulwinder Singh
05/16/2019, 11:42 AMisCompleted
working as i'm expecting, i have checked its not throwing an error, but i need confirmation for thisDico
05/16/2019, 11:52 AMisCompleted
doesn't indicate whether it was started reliably.bdawg.io
05/16/2019, 6:24 PMisCompleted
just informs you if it will no longer execute. !isActive && !isCancelled && isCompleted
would both need to be checked that it was completed normally. You can figure out which combination(s) you need to check by referencing the states table on the Job docs
https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-job/Dico
05/16/2019, 7:39 PM