UNPKG

@mlightcad/common

Version:

The common package provides shared utilities and base classes that are used across the RealDWG-Web ecosystem. This package contains fundamental components for color management, event handling, logging, performance monitoring, and file loading operations.

48 lines 2.07 kB
/** * The minimal basic Event that can be dispatched by a {@link AcCmEventDispatcher<>}. */ export interface AcCmBaseEvent<TEventType extends string = string> { readonly type: TEventType; } /** * The minimal expected contract of a fired Event that was dispatched by a {@link AcCmEventDispatcher<>}. */ export interface AcCmEvent<TEventType extends string = string, TTarget = unknown> { readonly type: TEventType; readonly target: TTarget; } export type AcCmEventListener<TEventData, TEventType extends string, TTarget> = (event: TEventData & AcCmEvent<TEventType, TTarget>) => void; export declare class AcCmEventDispatcher<TEventMap extends {} = {}> { /** * Index a record of all callback functions */ private _listeners; /** * Creates {@link AcCmEventDispatcher} object. */ constructor(); /** * Add 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<T extends Extract<keyof TEventMap, string>>(type: T, listener: AcCmEventListener<TEventMap[T], T, this>): void; /** * Check 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<T extends Extract<keyof TEventMap, string>>(type: T, listener: AcCmEventListener<TEventMap[T], T, this>): boolean; /** * Remove 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<T extends Extract<keyof TEventMap, string>>(type: T, listener: AcCmEventListener<TEventMap[T], T, this>): void; /** * Fire an event type. * @param event The event that gets fired. */ dispatchEvent<T extends Extract<keyof TEventMap, string>>(event: AcCmBaseEvent<T> & TEventMap[T]): void; } //# sourceMappingURL=AcCmEventDispatcher.d.ts.map