angular-l10n
Version:
An Angular library to translate messages, dates and numbers
48 lines • 1.33 kB
JavaScript
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
*/
import { Injectable } from "@angular/core";
import { ReplaySubject } from "rxjs";
var Caching = /** @class */ (function () {
function Caching() {
this.cache = {};
}
/**
* @param {?} key
* @param {?} request
* @return {?}
*/
Caching.prototype.read = /**
* @param {?} key
* @param {?} request
* @return {?}
*/
function (key, request) {
var _this = this;
/** @type {?} */
var cached = this.cache[key];
if (cached)
return cached;
/** @type {?} */
var buffer = new ReplaySubject(1);
request.subscribe(function (value) { return buffer.next(value); }, function (error) {
buffer.error(error);
_this.cache[key] = undefined;
}, function () { return buffer.complete(); });
/** @type {?} */
var response = buffer.asObservable();
this.cache[key] = response;
return response;
};
Caching.decorators = [
{ type: Injectable }
];
return Caching;
}());
export { Caching };
if (false) {
/** @type {?} */
Caching.prototype.cache;
}
//# sourceMappingURL=caching.js.map