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

Dalinar

01/30/2019, 7:00 PM
I'm reading the docs here https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-deferred/ so
isCompleted
means cancelled or completed, `isCancelled`means cancelled, so to find out if it completed sucessfully there is no easier way than checking for
isCompleted && !isCanclled
?
a

ansman

01/30/2019, 7:15 PM
That is not enough if you want to handle failured
d

Dalinar

01/30/2019, 7:17 PM
sure, bad wording on my part - I mean, to find out if it completed without being cancelled
g

groostav

01/30/2019, 10:38 PM
I think the hope would be that you could express the successfulness of the operation in the "return value" from the job, either the published messages from the channel or the result from the Deferred. Trying to investigate the state of a coroutine by interrogating its job is likely going to lead to more brittle code than if you encoded the sucess or failure in its output values.
3 Views