Hi, I'm working again on Android's callback hell b...
# coroutines
l
Hi, I'm working again on Android's callback hell based Camera2 API, resuming work on an open source library to implement structured concurrency in the bast possible way. My questions are the following: 1. How to cancel a scope (based on an error callback) with a specific exception? In my case, in a local
coroutineScope { ... }
, I have an
async
block that needs to be cancelled if some error callback comes in, and that exception coming in is the cause of the cancellation, so
CoroutineScope.cancel()
doesn't suit my needs. 2. Is using
CompleteableDeferred<T>(coroutineContext[Job])
safe? My guess is that it will cancel the scope with the proper exception if its
completeExceptionnaly(…)
function is called, and it will itself be cancelled if the scope is cancelled from another place. Am I right about this? If so, I'm wondering why there's no
completableDeferred<T>()
extension function for
CoroutineScope
that would do it without needing to pass
coroutineContext[Job]
.
d
Hi @louiscad, I don't have an answer for you, but having worked with that API before, I just wanted to salute your effort to tame it 🙂
👍 1
🙂 2