there doesn't seem to be a cancelation hook when b...
# coroutines
j
there doesn't seem to be a cancelation hook when building a
Deferred
(via
CompletableDeferred
). Is there something else that offers this callback?
e
invokeOnCompletion
is there. Or what else are you looking for?
j
I'm wrapping Retrofit's Call. It completes with a result or completes exceptionally. I want to propagate cancellation of the Deferred up into the Call though.
e
Use
invokeOnCompletion
and cancel call from there. It should work assuming that cancelling an otherwise completed call has no effect.
j
It's meant to be cheap.
e
You can also extend
JobSupport
just like
CompletableDeferred
. In this case,
onCancellation
can be overriden. Less stable API, but less overhead.
j
Can you clarify what you mean by less stable? I thought binary compatibility was guaranteed despite the experimental status.
Ah, I think I see it. There are warnings that it is an unstable API.