will barSuspendedFun wait until the completion of fooSuspendedFun, or do you need to use something to await the return of the first function?
j
Joffrey
06/13/2022, 1:46 PM
barSuspendedFun
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 row
e
ephemient
06/13/2022, 1:48 PM
the only functions to do leave the linear control flow that should take a
CoroutineScope
parameter, such as
launch
and its receiver
ephemient
06/13/2022, 1:49 PM
if a function doesn't take a
CoroutineScope
(and doesn't break structured concurrency by using
GlobalScope
or creating its own scope), then it is guaranteed to complete before the next function