import EventEmitter from "eventemitter3"; import { AskEventDefinition, AskEventHandler, CallEventHandler, EventDefinition, HookEventHandler, PipeEventHandler } from "../../types/EventHandler"; declare class KuzzleEventEmitter extends EventEmitter { private coreAnswerers; private coreSyncedAnswerers; private corePipes; private pipeRunner; private pluginPipes; private pluginPipeDefinitions; private superEmit; constructor(maxConcurrentPipes: number, pipesBufferSize: number); /** * Registers a core method on a pipe * Note: core methods cannot listen to wildcarded events, only exact matching * works here. */ onPipe(event: TEventDefinition["name"], fn: PipeEventHandler): void; /** * Registers a core 'ask' event answerer * There can only be 0 or 1 answerer per ask event. */ onAsk(event: TAskEventDefinition["name"], fn: AskEventHandler): void; /** * Registers a core 'callback' answerer * There can only be 0 or 1 answerer per callback event. */ onCall(event: TAskEventDefinition["name"], fn: CallEventHandler): void; /** * Emits an event and all its wildcarded versions * * @warning Critical section of code */ emit(event: string | symbol, ...args: any[]): boolean; /** * Emits a pipe event, which triggers the following, in that order: * 1. Plugin pipes are invoked one after another (waterfall). Each plugin must * resolve the pipe (with a callback or a promise) with a similar payload * than the one received * 2. Core pipes are invoked in parallel. They are awaited for (promises-only) * but their responses are neither evaluated nor used * 3. Hooks are invoked in parallel. They are not awaited. * * Accepts a callback argument (to be used by pipes invoked before the funnel * overload-protection mechanism). If a callback is provided, this method * doesn't return a promise. * * @warning Critical section of code */ pipe(event: TEventDefinition["name"], ...payload: TEventDefinition["args"]): Promise | null; /** * Emits an "ask" event to get information about the provided payload */ ask(event: TAskEventDefinition["name"], ...args: [payload?: TAskEventDefinition["payload"], ...rest: any]): Promise; /** * Calls a callback to get information about the provided payload */ call(event: TAskEventDefinition["name"], ...args: [payload?: TAskEventDefinition["payload"], ...rest: any]): TAskEventDefinition["result"]; /** * Registers a plugin hook. * Catch any error in the handler and emit the hook:onError event. */ registerPluginHook(pluginName: string, event: TEventDefinition["name"], fn: HookEventHandler): void; registerPluginPipe(event: TEventDefinition["name"], handler: PipeEventHandler): string; unregisterPluginPipe(pipeId: string): void; /** * Checks if an ask event has an answerer */ hasAskAnswerer(event: string): boolean; } export default KuzzleEventEmitter;