angular-cached-resource
Version:
An AngularJS module to interact with RESTful resources, even when browser is offline
36 lines (27 loc) • 935 B
JavaScript
// Generated by CoffeeScript 1.7.1
var CachedResourceManager, ResourceWriteQueue;
ResourceWriteQueue = require('./resource_write_queue');
CachedResourceManager = (function() {
function CachedResourceManager($timeout) {
this.$timeout = $timeout;
this.queuesByKey = {};
}
CachedResourceManager.prototype.add = function(CachedResource) {
return this.queuesByKey[CachedResource.$key] = new ResourceWriteQueue(CachedResource, this.$timeout);
};
CachedResourceManager.prototype.getQueue = function(CachedResource) {
return this.queuesByKey[CachedResource.$key];
};
CachedResourceManager.prototype.flushQueues = function() {
var key, queue, _ref, _results;
_ref = this.queuesByKey;
_results = [];
for (key in _ref) {
queue = _ref[key];
_results.push(queue.flush());
}
return _results;
};
return CachedResourceManager;
})();
module.exports = CachedResourceManager;