configcat-common
Version:
ConfigCat is a configuration as a service that lets you manage your features and configurations without actually deploying new code.
46 lines (45 loc) • 2.24 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ManualPollConfigService = void 0;
var tslib_1 = require("tslib");
var ConfigServiceBase_1 = require("./ConfigServiceBase");
var ManualPollConfigService = /** @class */ (function (_super) {
tslib_1.__extends(ManualPollConfigService, _super);
function ManualPollConfigService(configFetcher, options) {
var _this = _super.call(this, configFetcher, options) || this;
var initialCacheSyncUp = _this.syncUpWithCache();
_this.readyPromise = _this.getReadyPromise(initialCacheSyncUp, function (initialCacheSyncUp) { return tslib_1.__awaiter(_this, void 0, void 0, function () { var _a; return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = this.getCacheState;
return [4 /*yield*/, initialCacheSyncUp];
case 1: return [2 /*return*/, _a.apply(this, [_b.sent()])];
}
}); }); });
return _this;
}
ManualPollConfigService.prototype.getCacheState = function (cachedConfig) {
if (cachedConfig.isEmpty) {
return ConfigServiceBase_1.ClientCacheState.NoFlagData;
}
return ConfigServiceBase_1.ClientCacheState.HasCachedFlagDataOnly;
};
ManualPollConfigService.prototype.getConfig = function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
this.options.logger.debug("ManualPollService.getConfig() called.");
return [4 /*yield*/, this.options.cache.get(this.cacheKey)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
ManualPollConfigService.prototype.refreshConfigAsync = function () {
this.options.logger.debug("ManualPollService.refreshConfigAsync() called.");
return _super.prototype.refreshConfigAsync.call(this);
};
return ManualPollConfigService;
}(ConfigServiceBase_1.ConfigServiceBase));
exports.ManualPollConfigService = ManualPollConfigService;