Chris Fillmore
05/14/2021, 2:34 AMViewModelComponent
and ActivityRetainedComponent
?
I’m an idiot and took too long to realize that ActivityComponent
is not a descendant of ViewModelComponent
. So I’m wondering what is the advantage of ViewModelComponent
vs ActivityRetainedComponent
.
Thanks!FunkyMuse
05/14/2021, 7:15 AMChris Fillmore
05/14/2021, 12:46 PMAhmed Ibrahim
05/15/2021, 2:38 PMViewModelComponent
lives under ActivityRetainedComponent
, and it has the same lifecycle as of a `ViewModel`that is annotated with @HiltViewModel
.
The most obvious difference is that ViewModelComponent holds an instance to a SavedStateHandle
that belongs to a Fragment or an Activity. While ActivityRetainComponent
has nothing to do with the SavedStateHandle
of its Activity.Chris Fillmore
05/15/2021, 2:41 PM