Hi, let's say I have 3 coroutines: A,B and C. I wa...
# coroutines
d
Hi, let's say I have 3 coroutines: A,B and C. I want A and B be related, as in when A fails B cancels as well, and vice-a-versa. I also want C depend on A and B, but only one direction, so A and B failure would cancel C, but not other way around. There is probably simple way to do it, but I am confused now. I know of supervisor scope, but that makes all children equally unrelated, while I have some sort of downward hierarchy: PARENT / \ A - B \ / C
g
Maybe you could provide some examples how those coroutines are interact, otherwise it's not very clear Looks that you just can run a and b in one coroutineScope and from parent
d
they don't really interact, just want to manage failures better. Let me show you what I do currently:
Copy code
suspend fun callMany() = coroutineScope {
      launch { callA() }
      launch { callB() }
      
      CoroutineScope(this.coroutineContext + Job()).launch {
                callC()
      }
}
this way when callA() and callB() fail, they make callMany() throw an error and cancel each other, but callC() continues. I want callC() to be cancelled when callA() or callB() fails, but if callC() fails it woudn't affect callA() or callB(). While preserving the rest of functionality