diff --git a/source/documents/scripts/services/poems.js.coffee b/source/documents/scripts/services/poems.js.coffee index 43fd3b7..1ec0c65 100644 --- a/source/documents/scripts/services/poems.js.coffee +++ b/source/documents/scripts/services/poems.js.coffee @@ -1,15 +1,21 @@ angular.module("sideBySide").service "poems", ['$rootScope', '$q', 'fetch', ($rootScope, $q, fetch) -> poems = [] + loaded = false heading = undefined @update = (config) -> - fetch(config).then((result) -> - $q.all(result.promises).then((results) -> - poems = results - heading = result.heading - $rootScope.$emit "poemsLoaded" + if loaded == true + $rootScope.$emit "poemsLoaded" + else + fetch(config).then((result) -> + $q.all(result.promises).then((results) -> + poems = results + heading = result.heading + loaded = true + + $rootScope.$emit "poemsLoaded" + ) ) - ) @get = () -> poems