how does a ViewModel provider (something like ```s...
# android
s
how does a ViewModel provider (something like
Copy code
singleLargeTextInputViewModel = ViewModelProviders.of(this, SingleLargeInputViewModel.FACTORY(NetworkService())).get(
            SingleLargeInputViewModel::class.java
        )
) “know” (????) that a view model already exists? Or would it?
a
it fetches the
ViewModelStore
from the activity or fragment you gave it, which is tied into the nonConfigurationInstance mechanism of activity recreation. It just passes a map from old to new activity instance and stores viewmodels for you
s
Oh cool! I had no idea about the nonConfigurationInstance or that viewModelStore was a thing activities/fragments had.