mirror of
https://github.com/wassname/side-by-side.git
synced 2026-09-09 11:34:24 +08:00
Only fetch poems once
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user