Created
April 27, 2018 12:58
-
-
Save tpakis/c68f24ac7a09d3d15d718a1eb2466672 to your computer and use it in GitHub Desktop.
This file contains 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
//couple the activity with the view model | |
viewModel = ViewModelProviders.of(this).get(MainActivityViewModel.class); | |
//subscribe to LiveData | |
viewModel.getRecipesListObservable().observe(MainActivity.this, new Observer<Resource<List<Recipe>>>() { | |
@Override | |
public void onChanged(@Nullable Resource<List<Recipe>> recipes) { | |
Timber.d(recipes.status.toString()); | |
} | |
}); | |
//ask the viewmodel for data (maybe an event happened?or onCreate?) | |
viewModel.getData(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment