UNPKG

ng-config-cat

Version:

An Angular service for ConfigCat

20 lines 1.03 kB
import { createClientWithAutoPoll } from 'configcat-js'; import { Subject, merge } from 'rxjs'; import { distinctUntilChanged, switchMap } from 'rxjs/operators'; import { ConfigCatClient } from './config-cat-client'; export class ConfigCatAutoModeClient extends ConfigCatClient { constructor(sdkKey, configCatConfiguration) { super(); this.configChangeNotificator = new Subject(); this.client = createClientWithAutoPoll(sdkKey, { pollIntervalSeconds: configCatConfiguration.pollIntervalSeconds, configChanged: () => this.configChangeNotificator.next(), logger: configCatConfiguration.logger, requestTimeoutMs: configCatConfiguration.requestTimeoutMs, }); } getValue(key, defaultValue, user) { return merge(super.getValue(key, defaultValue, user), this.configChangeNotificator.pipe(switchMap(() => super.getValue(key, defaultValue, user)))).pipe(distinctUntilChanged()); } } //# sourceMappingURL=config-cat-auto-mode-client.js.map