I'm trying to understand why is ActivityRetainedScoped
introduced for DI in Hilt. It looks to me that the scope is identical to what ViewModelScoped
should do. I was under the impression that scoped worked like this:
AppScope (singleton) > ViewModelScope > ActivityScope > ViewScope > ...
But this graphic kinda hints that ViewModel and Activity scopes are... siblings?
According to the docs:
"ActivityRetainedComponent lives across configuration changes, so it is created at the first Activity#onCreate() and destroyed at the last Activity#onDestroy()."
Well, so does the view model, no? I'm pretty sure view models survive config changes (that's the whole point if having them in the first place)
What is ActivityRetainedScoped
? How is it different from VM scope? Why does google likes over complicating things that should be conceptually simple
https://developer.android.com/training/dependency-injection/hilt-android