From c3dbefbb4f3d9d41713d72a41e9ce906ccaeb50c Mon Sep 17 00:00:00 2001 From: Dan Elbert Date: Wed, 18 Apr 2018 17:04:25 -0500 Subject: [PATCH] caching --- app/javascript/components/TheLogCreator.vue | 3 +- app/javascript/components/TheRecipe.vue | 3 +- app/javascript/components/TheRecipeEditor.vue | 3 +- app/javascript/components/TheRecipeList.vue | 5 +- app/javascript/lib/Api.js | 62 ++++++++++++++----- app/javascript/store/index.js | 8 ++- app/javascript/styles/_variables.scss | 1 + app/views/home/sw.js.erb | 15 +++++ 8 files changed, 74 insertions(+), 26 deletions(-) diff --git a/app/javascript/components/TheLogCreator.vue b/app/javascript/components/TheLogCreator.vue index 81ecbc0..d657620 100644 --- a/app/javascript/components/TheLogCreator.vue +++ b/app/javascript/components/TheLogCreator.vue @@ -56,8 +56,7 @@ created() { this.loadResource( - api.getRecipe(this.recipeId) - .then(data => { this.log.recipe = data; return data; }) + api.getRecipe(this.recipeId, data => this.log.recipe = data) ); }, diff --git a/app/javascript/components/TheRecipe.vue b/app/javascript/components/TheRecipe.vue index 3a4ba72..172050c 100644 --- a/app/javascript/components/TheRecipe.vue +++ b/app/javascript/components/TheRecipe.vue @@ -59,8 +59,7 @@ methods: { refreshData() { this.loadResource( - api.getRecipe(this.recipeId, this.scale, this.system, this.unit) - .then(data => { this.recipe = data; return data; }) + api.getRecipe(this.recipeId, this.scale, this.system, this.unit, data => this.recipe = data) ); } }, diff --git a/app/javascript/components/TheRecipeEditor.vue b/app/javascript/components/TheRecipeEditor.vue index 6bc1326..7a22e0d 100644 --- a/app/javascript/components/TheRecipeEditor.vue +++ b/app/javascript/components/TheRecipeEditor.vue @@ -48,8 +48,7 @@ created() { this.loadResource( - api.getRecipe(this.recipeId) - .then(data => { this.recipe = data; return data; }) + api.getRecipe(this.recipeId, data => { this.recipe = data; return data; }) ); }, diff --git a/app/javascript/components/TheRecipeList.vue b/app/javascript/components/TheRecipeList.vue index 173e974..9d4597c 100644 --- a/app/javascript/components/TheRecipeList.vue +++ b/app/javascript/components/TheRecipeList.vue @@ -1,6 +1,6 @@