Skip to content

Instantly share code, notes, and snippets.

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