Tin Tran
09/01/2021, 7:47 AMclass MyViewModel:ViewModel() {
private val job = SupervisorJob()
private val scope = CoroutineScope(<http://Dispatcher.IO|Dispatcher.IO> + job)
fun test() {
viewModelScope.launch {
job1()
job.cancelAndJoin()
scope.launch {
job2()
}
}
}
}
Johannes Doll
09/01/2021, 7:55 AMCoroutineScope
) of the job you launch afterwards (the one containing job2()
). Does it work if you remove the job.cancelAndJoin()
line?Tin Tran
09/01/2021, 7:59 AMJohannes Doll
09/01/2021, 8:10 AMJohannes Doll
09/01/2021, 8:11 AMJoost Klitsie
09/01/2021, 8:21 AMJoost Klitsie
09/01/2021, 8:22 AMJohannes Doll
09/01/2021, 8:23 AMTin Tran
09/01/2021, 8:28 AMcancelChildren
works perfect. Thank you Joost and JohannesJoost Klitsie
09/01/2021, 10:23 AM