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
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