Hey does AssistedInject with Hilt support SharedVi...
# dagger
r
Hey does AssistedInject with Hilt support SharedViewModels, or will a new instance always be created?
n
What does SharedViewModels mean in this context? Like scoping it to an Activity but then accessing it in Fragments?
r
yea
h
You can specify a key nowadays or if you want to scope it to a graph of your nested navigation you can use hiltNavGraphViewModels(R.id.myGraphId) also if you instantiate the view model in the activity, you can use the owner of the by viewModel to be the fragment’s activity lifecycle owner
❤️ 1
1
n
To also answer your question more directly I would guess that the shared viewModel is created once lazily with whatever param you pass in via the Assisted injection in the Activity and all other calls to it would just grab the existing ViewModel but I think it would be worth testing to confirm that.
❤️ 1