Skip to content

Instantly share code, notes, and snippets.

@GauravChaddha1996
Created June 25, 2017 16:32
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
class RecipePresenter {
Model model;
View view;
List<Recipe> list;
RecipeData data;
// Make the constructor here and initialize the model and view
/* First and second role of presenter- asking model for data
on button click. Caching the recipes in 'data' variable and
then sending the results back */
void loadRecipes() {
try {
list = model.onLoadRecipes();
data.setRecipesList(list);
} catch (UpgradeAccountException exception) {
data.setError(true);
}
view.updateUI(data);
}
// Third role of presenter - transform data
void loadFilterRecipe() {
List<Recipe> filterList = list.someFilter();
data.setRecipesList(filterList);
view.updateUI(data);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment