diff options
| author | Shyam Seshadri | 2010-06-23 13:07:31 -0700 |
|---|---|---|
| committer | Shyam Seshadri | 2010-06-23 13:07:31 -0700 |
| commit | 42257f22af643fc5e91162cc99adeef32916fd28 (patch) | |
| tree | 85f78cf493e79a44fc02d4749da681296d83dcea /src/services.js | |
| parent | 70c3dc81665191cd065a5303e5e26639a0023a73 (diff) | |
| download | angular.js-42257f22af643fc5e91162cc99adeef32916fd28.tar.bz2 | |
wilford's changes to serve cached data and then fetch from server if needed / specified
Diffstat (limited to 'src/services.js')
| -rw-r--r-- | src/services.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/services.js b/src/services.js index 5f42ef18..64f2ea4f 100644 --- a/src/services.js +++ b/src/services.js @@ -313,7 +313,7 @@ angularService('$xhr.bulk', function($xhr, $error, $log){ angularService('$xhr.cache', function($xhr){ var inflight = {}, self = this;; - function cache(method, url, post, callback){ + function cache(method, url, post, callback, cacheThenRetrieve){ if (isFunction(post)) { callback = post; post = null; @@ -322,7 +322,11 @@ angularService('$xhr.cache', function($xhr){ var data; if (data = cache.data[url]) { callback(200, copy(data.value)); - } else if (data = inflight[url]) { + if (!cacheThenRetrieve) + return; + } + + if (data = inflight[url]) { data.callbacks.push(callback); } else { inflight[url] = {callbacks: [callback]}; @@ -340,6 +344,7 @@ angularService('$xhr.cache', function($xhr){ }); }); } + } else { cache.data = {}; cache.delegate(method, url, post, callback); |
