configcat-common
Version:
ConfigCat is a configuration as a service that lets you manage your features and configurations without actually deploying new code.
47 lines • 2.62 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 is ready to provide the actual value of feature flags or settings. */
clientReady: [cacheState: ClientCacheState];
/** Occurs after the value of a feature flag of setting has been evaluated. */
flagEvaluated: [evaluationDetails: IEvaluationDetails];
/** Occurs after the locally cached config has been updated. */
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