tggl-client
Version:
Tggl Typescript SDK for client and server
34 lines (33 loc) • 1.6 kB
TypeScript
import { TgglConfig, TgglContext, TgglFlags, TgglFlagSlug, TgglFlagValue, TgglLocalClientOptions } from './types';
import { TgglReporting } from './TgglReporting';
export declare class TgglLocalClient<TFlags extends TgglFlags = TgglFlags, TContext extends TgglContext = TgglContext> {
private apiKey?;
private url;
private config;
private pollingInterval;
private timeoutID?;
private fetchID;
private lastSuccessfulFetchID;
private lastSuccessfulFetchResponse;
private fetchPromise?;
private onConfigChangeCallbacks;
private onFetchSuccessfulCallbacks;
private onFetchFailCallbacks;
private log;
protected reporting: TgglReporting | null;
constructor(apiKey?: string | null | undefined, options?: TgglLocalClientOptions<TFlags>);
onConfigChange(callback: (config: TgglConfig<TFlags>) => void): () => void;
onFetchSuccessful(callback: () => void): () => void;
onFetchFail(callback: (error: Error) => void): () => void;
startPolling(pollingInterval: number): void;
stopPolling(): void;
private planNextPolling;
private cancelNextPolling;
private waitForLastFetchToFinish;
fetchConfig(): Promise<TgglConfig<TFlags>>;
getConfig(): TgglConfig<TFlags>;
setConfig(config: TgglConfig<TFlags>): void;
private setRawConfig;
get<TSlug extends TgglFlagSlug<TFlags>, TDefaultValue = TgglFlagValue<TSlug, TFlags>>(context: Partial<TContext>, slug: TSlug, defaultValue: TDefaultValue): TgglFlagValue<TSlug, TFlags> | TDefaultValue;
getActiveFlags(context: Partial<TContext>): Partial<TFlags>;
}