Dec 22, 2020
Certainly you can do that using withContext() and avoid having to cancel the coroutine manually, it might depend on your use case but definitely it is a good approach. Just take in mind that viewModelScope uses the main dispatcher, so by default coroutines run in the main thread