AdalPari
12/10/2020, 6:59 PMsuspend fun foo1() // function
suspend fun foo2() // function
First approach:
// sequential code
viewModelScope.launch { foo1() }
// more sequential code
viewModelScope.launch { foo2() }
// more sequential code}
Second approach:
viewModelScope.launch {
// sequential code
foo1()
// more sequential code
foo2()
// more sequential code
}
I've also saw this second approach with async
calls inside the main launch
one.
Thanks!bezrukov
12/10/2020, 7:13 PMtseisel
12/10/2020, 7:31 PMAdalPari
12/10/2020, 7:44 PMsuspend
functionsfoo1()
(suspend) is finished, while in the first example it will run because foo1()
call runs independenttseisel
12/10/2020, 7:50 PMAdalPari
12/10/2020, 7:51 PM