EventElement Interface
An event-emitting interface that allows for type-safe event handling.
export declare interface EventElement<TEventMap extends {
[key: string]: any;
}>
Remarks
This interface provides a generic way to handle events with strongly-typed event data. It supports both synchronous and asynchronous event listeners, allowing for flexible event handling patterns.
Methods
addEventListener(K, (event: TEventMap[K]) => void)
Adds an event listener for the specified event type.
addEventListener<K extends keyof TEventMap & string>(type: K, listener: (event: TEventMap[K]) => void): void;
Parameters
-
type
The event type/name to listen for.
-
listener
The callback function that will be invoked when the event is emitted.
Remarks
Multiple listeners can be registered for the same event type. The listener will be called with the strongly-typed event data when the event is emitted.