Do we really need ViewModels if our Dagger components are scoped correctly ?
In the article you mention that we care about ViewModels because :
they live oustide Activity/Fragments -> this is also true for your scoped subcomponents inside the Dagger graph. Rotations could be handled with only Dagger
they live inside Activity/Fragments, notifying the LiveData observer only on the started state -> this is handled by LiveData and the LifecycleOwner (Activity/Fragment), but ViewModel are not necessary for this to work
IMO if the Dagger graph is well scoped, we could get all the benefits that you are describing in this (valuable) article, without bothering with ViewModel.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi Tony !
Do we really need
ViewModel
s if our Dagger components are scoped correctly ?In the article you mention that we care about
ViewModel
s because :they live oustide Activity/Fragments -> this is also true for your scoped subcomponents inside the Dagger graph. Rotations could be handled with only Dagger
they live inside Activity/Fragments, notifying the LiveData observer only on the
started
state -> this is handled by LiveData and the LifecycleOwner (Activity/Fragment), butViewModel
are not necessary for this to workIMO if the Dagger graph is well scoped, we could get all the benefits that you are describing in this (valuable) article, without bothering with
ViewModel
.