voben
05/13/2020, 3:19 AMdoSomethingElse()
get called before the network call completes? How could I improve this?
suspend fun signOut() {
coroutineScope {
launch {
makeNetworkRequest() // suspending function
}
}
doSomethingElse()
}
octylFractal
05/13/2020, 3:24 AMcoroutineScope
will suspend until the launch
is finishedCoroutineScope
to start it on, or as a last resort you can use GlobalScope
doSomethingElse()
, but still wait for it to complete before signOut()
finishes, then move doSomethingElse()
inside the coroutineScope
blockgregd
05/13/2020, 2:26 PMvoben
05/13/2020, 2:33 PMgregd
05/13/2020, 2:38 PM