UNPKG

@libp2p/interfaces

Version:
28 lines 1.31 kB
export interface EventCallback<EventType> { (evt: EventType): void; } export interface EventObject<EventType> { handleEvent: EventCallback<EventType>; } export type EventHandler<EventType> = EventCallback<EventType> | EventObject<EventType>; /** * Adds types to the EventTarget class. Hopefully this won't be necessary forever. * * https://github.com/microsoft/TypeScript/issues/28357 * https://github.com/microsoft/TypeScript/issues/43477 * https://github.com/microsoft/TypeScript/issues/299 * etc */ export declare class EventEmitter<EventMap extends Record<string, any>> extends EventTarget { #private; listenerCount(type: string): number; addEventListener<K extends keyof EventMap>(type: K, listener: EventHandler<EventMap[K]> | null, options?: boolean | AddEventListenerOptions): void; removeEventListener<K extends keyof EventMap>(type: K, listener?: EventHandler<EventMap[K]> | null, options?: boolean | EventListenerOptions): void; dispatchEvent(event: Event): boolean; safeDispatchEvent<Detail>(type: keyof EventMap, detail: CustomEventInit<Detail>): boolean; } export declare const CustomEvent: { new <T>(type: string, eventInitDict?: CustomEventInit<T> | undefined): CustomEvent<T>; prototype: CustomEvent<any>; }; //# sourceMappingURL=events.d.ts.map