configcat-common
Version:
ConfigCat is a configuration as a service that lets you manage your features and configurations without actually deploying new code.
60 lines • 3.51 kB
TypeScript
import type { ClientCacheState } from "./ConfigServiceBase";
import type { IEventEmitter, IEventProvider } from "./EventEmitter";
import type { IConfig } from "./ProjectConfig";
import type { IEvaluationDetails } from "./RolloutEvaluator";
/** Hooks (events) that can be emitted by `ConfigCatClient`. */
export declare type HookEvents = {
/**
* Occurs when the client reaches the ready state, i.e. completes initialization.
*
* @remarks Ready state is reached as soon as the initial sync with the external cache (if any) completes.
* If this does not produce up-to-date config data, and the client is online (i.e. HTTP requests are allowed),
* the first config fetch operation is also awaited in Auto Polling mode before ready state is reported.
*
* That is, reaching the ready state usually means the client is ready to evaluate feature flags and settings.
* However, please note that this is not guaranteed. In case of initialization failure or timeout, the internal cache
* may be empty or expired even after the ready state is reported. You can verify this by checking the `cacheState` parameter.
*/
clientReady: [cacheState: ClientCacheState];
/** Occurs after the value of a feature flag of setting has been evaluated. */
flagEvaluated: [evaluationDetails: IEvaluationDetails];
/**
* Occurs after the internally cached config has been updated to a newer version, either as a result of synchronization
* with the external cache, or as a result of fetching a newer version from the ConfigCat CDN.
*/
configChanged: [newConfig: IConfig];
/** Occurs in the case of a failure in the client. */
clientError: [message: string, exception?: any];
};
/** Defines hooks (events) for providing notifications of `ConfigCatClient`'s actions. */
export interface IProvidesHooks extends IEventProvider<HookEvents> {
}
export declare class Hooks implements IProvidesHooks, IEventEmitter<HookEvents> {
private eventEmitter;
constructor(eventEmitter: IEventEmitter);
tryDisconnect(): boolean;
/** @inheritdoc */
addListener: <TEventName extends keyof HookEvents>(eventName: TEventName, listener: (...args: HookEvents[TEventName]) => void) => this;
/** @inheritdoc */
on<TEventName extends keyof HookEvents>(eventName: TEventName, listener: (...args: HookEvents[TEventName]) => void): this;
/** @inheritdoc */
once<TEventName extends keyof HookEvents>(eventName: TEventName, listener: (...args: HookEvents[TEventName]) => void): this;
/** @inheritdoc */
removeListener<TEventName extends keyof HookEvents>(eventName: TEventName, listener: (...args: HookEvents[TEventName]) => void): this;
/** @inheritdoc */
off: <TEventName extends keyof HookEvents>(eventName: TEventName, listener: (...args: HookEvents[TEventName]) => void) => this;
/** @inheritdoc */
removeAllListeners(eventName?: keyof HookEvents): this;
/** @inheritdoc */
listeners(eventName: keyof HookEvents): Function[];
/** @inheritdoc */
listenerCount(eventName: keyof HookEvents): number;
/** @inheritdoc */
eventNames(): Array<keyof HookEvents>;
/** @inheritdoc */
emit<TEventName extends keyof HookEvents>(eventName: TEventName, ...args: HookEvents[TEventName]): boolean;
}
export declare type SafeHooksWrapper = {
emit<TEventName extends keyof HookEvents>(eventName: TEventName, ...args: HookEvents[TEventName]): boolean;
};
//# sourceMappingURL=Hooks.d.ts.map