@4players/odin
Version:
A cross-platform SDK enabling developers to integrate real-time VoIP chat technology into their projects
30 lines (29 loc) • 1.23 kB
TypeScript
/**
* Interface describing a custom event containing payload.
*/
export interface IOdinEvent<T> extends Event {
/**
* Custom payload of the event (see `IOdin*Payload` interfaces).
*/
readonly payload: T;
}
/**
* Custom Event providing Odin Event Payload of a provided type.
*/
export declare class OdinEvent<T> extends Event implements IOdinEvent<T> {
readonly payload: T;
constructor(type: string, payload: T);
}
/**
* A generic event target class designed for strongly-typed event handling.
* OdinEventTarget extends the functionality of the standard EventTarget to allow
* interactions with predefined event types and handlers.
*
* @template Events The mapping of event type names to handler callback signatures.
*/
export declare class OdinEventTarget<Events> {
private _eventTarget;
addEventListener<OdinEventType extends keyof Events>(eventName: OdinEventType, handler: Events[OdinEventType], options?: boolean | AddEventListenerOptions): void;
dispatchEvent<T extends OdinEvent<any>>(event: T): void;
removeEventListener<OdinEventType extends keyof Events>(type: OdinEventType | string, callback: EventListenerOrEventListenerObject | null | Events[OdinEventType]): void;
}