Created
May 25, 2018 17:56
-
-
Save joseprl89/31b55460b504db224b17dfdd50778212 to your computer and use it in GitHub Desktop.
How ViewModelStore works for https://medium.com/@josep.rodriguez/internals-of-android-architecture-components-part-i-the-viewmodel-d893e362a0d9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final void put(String key, ViewModel viewModel) { | |
ViewModel oldViewModel = mMap.get(key); | |
if (oldViewModel != null) { | |
oldViewModel.onCleared(); | |
} | |
mMap.put(key, viewModel); | |
} | |
final ViewModel get(String key) { | |
return mMap.get(key); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment