Add fetcher

This commit is contained in:
Vit Brunner
2013-06-18 00:00:59 +01:00
parent 73cea13621
commit b65460d74e
4 changed files with 37 additions and 38 deletions
@@ -0,0 +1,16 @@
angular.module("sideBySide").factory "fetch", ['$http', 'readerFactory', ($http, readerFactory) ->
# Fetch
#
# @param file [String] Path to config file
# @return TODO
return (file = "config.json") ->
$http.get(file).then((response) ->
promises = []
for poem in response.data.files
promises.push($http.get(poem).then((response) ->
reader = readerFactory(poem)
return reader(response.data)
))
return promises
)
]