Do we need to call `viewModelScope.cancel()` In V...
# android
a
Do we need to call
viewModelScope.cancel()
In ViewModels? I see that the documentation for ViewModel.kt says:
* This scope will be canceled when ViewModel will be cleared, i.e [ViewModel.onCleared] is called
But I can't find the code that actually calls
close()
f
No you do not need to, look into the
viewModelScope
implementation
👍 2
a
Ah thanks. I see it now. The getter puts the
viewModelScope
in the
bagOfTags
using
setTagIfAbsent
. And that's closed when
ViewModel.clear()
is called. Great, thanks!
100 Views