import { DisposableStore } from '../lifecycle'; /** * A function that is called when an event is emitted. */ export type EventListener = (data: T) => any; /** * A function that can be called to remove a previously attached event listener. */ export type EventUnsubscribe = () => void; export interface EventUnsubscribeStore { /** * Add an event unsubscribe handler * @param unsub */ add(unsub: EventUnsubscribe): void; /** * Call all event unsubscribes and clear store */ clear(): void; } /** * A function that can be called to attach an event listener. * * Listeners are called in the order they are attached. */ export type Event = (listener: EventListener, thisArgs?: any, store?: EventUnsubscribe[] | EventUnsubscribeStore | DisposableStore) => EventUnsubscribe; export declare namespace Event { const None: Event; /** * Given an event, returns another event which only fires once. */ function once(event: Event): Event; function debouncedListener(event: Event, listener: (data: O) => any, merge: (last: O | undefined, event: T) => O, delay?: number, leading?: boolean): EventUnsubscribe; /** * Given an event, returns the same event but typed as `Event`. */ function signal(event: Event): Event; function toPromise(event: Event): Promise; function runAndSubscribe(event: Event, handler: (e: T | undefined) => any): EventUnsubscribe; interface NodeEventEmitter { on(event: string | symbol, listener: Function): unknown; removeListener(event: string | symbol, listener: Function): unknown; } function fromNodeEventEmitter(emitter: NodeEventEmitter, eventName: string, map?: (...args: any[]) => T): Event; interface DOMEventEmitter { addEventListener(event: string | symbol, listener: Function): void; removeEventListener(event: string | symbol, listener: Function): void; } function fromDOMEventEmitter(emitter: DOMEventEmitter, eventName: string, map?: (...args: any[]) => T): Event; }