Skip to content

Instantly share code, notes, and snippets.

@GauravChaddha1996
Created June 25, 2017 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GauravChaddha1996/2fb978c8e18b1e8380a32041bd0d0c2c to your computer and use it in GitHub Desktop.
Save GauravChaddha1996/2fb978c8e18b1e8380a32041bd0d0c2c to your computer and use it in GitHub Desktop.
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