Cody Mikol
06/13/2022, 1:44 PMscope.launch {
fooSuspendedFun()
barSuspendedFun()
}
will barSuspendedFun wait until the completion of fooSuspendedFun, or do you need to use something to await the return of the first function?Joffrey
06/13/2022, 1:46 PMbarSuspendedFun
will wait for fooSuspendedFun
. The idea of Kotlin coroutines design is that if it looks like a regular function call, it behaves somewhat like a regular function call (suspend or not). So imagine it behaves similarly to seeing 2 regular function calls in a rowephemient
06/13/2022, 1:48 PMCoroutineScope
parameter, such as launch
and its receiverephemient
06/13/2022, 1:49 PMCoroutineScope
(and doesn't break structured concurrency by using GlobalScope
or creating its own scope), then it is guaranteed to complete before the next functionCody Mikol
06/13/2022, 1:50 PM