aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Resource.js6
-rw-r--r--src/services.js9
2 files changed, 11 insertions, 4 deletions
diff --git a/src/Resource.js b/src/Resource.js
index 724121b7..6ee0b1cf 100644
--- a/src/Resource.js
+++ b/src/Resource.js
@@ -94,6 +94,8 @@ ResourceFactory.prototype = {
function(status, response) {
if (status == 200) {
if (action.isArray) {
+ if (action.cacheThenRetrieve)
+ value = [];
foreach(response, function(item){
value.push(new Resource(item));
});
@@ -104,7 +106,8 @@ ResourceFactory.prototype = {
} else {
throw {status: status, response:response, message: status + ": " + response};
}
- }
+ },
+ action.cacheThenRetrieve
);
return value;
};
@@ -135,4 +138,3 @@ ResourceFactory.prototype = {
return Resource;
}
};
-
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);