UNPKG

kuzzle-sdk

Version:
32 lines (31 loc) 1.81 kB
type ListenerFunction = (...args: unknown[]) => unknown; export type PublicKuzzleEvents = "callbackError" | "connected" | "discarded" | "disconnected" | "loginAttempt" | "beforeLogin" | "afterLogin" | "logoutAttempt" | "beforeLogout" | "afterLogout" | "networkError" | "offlineQueuePush" | "offlineQueuePop" | "queryError" | "reAuthenticated" | "reconnected" | "reconnectionError" | "tokenExpired"; type PrivateKuzzleEvents = "connect" | "reconnect" | "disconnect" | "offlineQueuePush" | "websocketRenewalStart" | "websocketRenewalDone"; /** * For internal use only */ export type PrivateAndPublicSDKEvents = PublicKuzzleEvents | PrivateKuzzleEvents; /** * @todo proper TS conversion */ export declare class KuzzleEventEmitter { private _events; constructor(); private _exists; listeners(eventName: PrivateAndPublicSDKEvents): ListenerFunction[]; addListener(eventName: PrivateAndPublicSDKEvents, listener: ListenerFunction, once?: boolean): this; on(eventName: PrivateAndPublicSDKEvents, listener: (args: any) => void): this; prependListener(eventName: any, listener: any, once?: boolean): this; addOnceListener(eventName: any, listener: any): this; once(eventName: any, listener: any): this; prependOnceListener(eventName: any, listener: any): this; removeListener(eventName: PrivateAndPublicSDKEvents, listener: () => void): this; removeListener(eventName: string, listener: () => void): this; removeAllListeners(eventName?: PrivateAndPublicSDKEvents): this; removeAllListeners(eventName?: string): this; emit(eventName: PrivateAndPublicSDKEvents, ...payload: unknown[]): boolean; emit(eventName: string, ...payload: unknown[]): boolean; eventNames(): string[]; listenerCount(eventName: PrivateAndPublicSDKEvents): number; } export {};