export interface EventCallback { (...args: any[]): void; } export interface EventSelector { (...args: any[]): Parameters; } export interface MonotypeEventSelector { (...args: Parameters): Parameters; } export interface OptionsSelector { (...options: any[]): any[]; } /** An object which allows the addition, removal, and invocation of listener functions. */ declare type CoreEvent = { /** * Registers an event listener callback to an event. * @param callback Called when an event occurs. The parameters of this function depend on the type of event. * The callback parameter should be a function that looks like this: * function() {...}; */ addListener(callback: C): void; /** * @param callback Listener whose registration status shall be tested. */ hasListener(callback: C): boolean; hasListeners(): boolean; /** * Deregisters an event listener callback from an event. * @param callback Listener that shall be unregistered. * The callback parameter should be a function that looks like this: * function() {...}; */ removeListener(callback: C): void; }; declare type Callable | EventSelector> = { /** * Calls all listeners with a data argument. */ callListeners: (...args: Parameters) => void; /** * Remove all listeners */ clearListeners(): void; /** * Get the listener Set */ getListeners(): Set; /** * Returns CallableEvent without callListeners */ toEvent(): CoreEvent; }; export declare type CallableEvent | EventSelector> = CoreEvent & Callable; export declare const createEvent: (selector: EventSelector, validator?: OptionsSelector | undefined) => CallableEvent>; /** * Create an event that takes a single callback as an argument * * @export * @template C The callback signature * @template R The event selector signature * @param {R} selector Validate a call to callListeners and map it to the callback arguments * @returns {CallableEvent} */ export declare function createSetEvent | MonotypeEventSelector>(selector: R): CallableEvent; /** * Create an event that takes a single callback and any number of option arguments * * @export * @template C The listener callback signature. Will be called with the result of the event selector * @template E The event selector function signature. Will be called with the result of the options selector and the arguments for callListeners * @template O The options selector function signature. Will be called with the options arguments from addListener * @param {E} eventSelector Validate a call to callListeners and map it to the callback arguments * @param {O} [optionsSelector] Validate the options arguments passed to addListener * @returns {CallableEvent} */ export declare function createMapEvent | MonotypeEventSelector, O extends OptionsSelector>(eventSelector: E, optionsSelector?: O): CallableEvent; export {};