Newbie question with coroutines :-)
With coroutines that doesn't return a value, is there a way to execute some code upon the completion of that coroutine ?
In this example, funcA() performs some async call and upon completion funcB, funcC needs to complete, the rest of the code can continue to execute independent of funcA() completion
... other code executing
... other code executing
launch {
funcA()
}
funcB()
funcC()
... other code executing
... other code executing
One approach would be to enclose funcB, funcC within a method and we can use async with await ... but why return a value just for that.
i.e.
executeFunBC()
{
funcB()
funcC()
}
launch {
val result = funcA()
}
executeFunBC(result).await()
Basically, in some languages you can use 'blocks' or closures and execute some code upon completion of that block in the same method. (similar to callbacks)
Back to my question:
Is there a way to define the execution of funcB, funcC upon the completion of funcA() in the same function ?