Last active
May 25, 2018 17:55
-
-
Save joseprl89/c64e22c77eda3859838d85f70995bbe1 to your computer and use it in GitHub Desktop.
Sample code of how ViewModels are consumed 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
public void onCreate(Bundle savedInstanceState) { | |
MyViewModel model = ViewModelProviders.of(this).get(MyViewModel.class); | |
model.getUsers().observe(this, users -> { | |
// update UI | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment