/** * The minimal basic Event that can be dispatched by a {@link EventDispatcher<>}. */ export interface BaseEvent { readonly type: TEventType; target: any; } /** * The minimal expected contract of a fired Event that was dispatched by a {@link EventDispatcher<>}. */ export interface Event { readonly type: TEventType; readonly target: TTarget; } export type EventListener = (event: TEventData & Event) => void; export declare class EventDispatcher { private _listeners; /** * Adds a listener to an event type. * @param type The type of event to listen to. * @param listener The function that gets called when the event is fired. */ addEventListener>(type: T, listener: EventListener): void; /** * Checks if listener is added to an event type. * @param type The type of event to listen to. * @param listener The function that gets called when the event is fired. */ hasEventListener>(type: T, listener: EventListener): boolean; /** * Removes a listener from an event type. * @param type The type of the listener that gets removed. * @param listener The listener function that gets removed. */ removeEventListener>(type: T, listener: EventListener): void; /** * Fire an event type. * @param event The event that gets fired. */ dispatchEvent>(event: BaseEvent & TEventMap[T]): void; }