Tran Thang
11/19/2022, 11:00 AMJoffrey
11/19/2022, 11:00 AMcoroutineScope are you referring to?Tran Thang
11/19/2022, 11:04 AMTran Thang
11/19/2022, 11:04 AMJoffrey
11/19/2022, 11:07 AMcoroutineScope itself completes.Joffrey
11/19/2022, 11:09 AMviewModelScope, on the other hand, is a property of type CoroutineScope provided by some Android components. It is a coroutine scope whose lifecycle is tied to that of the view model you're using it in. It allows to start coroutines that will be automatically cancelled when the view model is not used anymore.Joffrey
11/19/2022, 11:11 AMcoroutineScope is not required per se, because launch already provides a scope, but the author wanted to catch exceptions thrown by the network calls done in async { } coroutines. If the async coroutines were started directly in the scope of launch, there would be no way to catch these exceptions.Tran Thang
11/19/2022, 11:15 AMTran Thang
11/19/2022, 11:15 AM