UNPKG

1.09 kBTypeScriptView Raw
1import { Disposable } from './disposable';
2/**
3 * Represents a typed event.
4 */
5export interface Event<T> {
6 /**
7 *
8 * @param listener The listener function will be called when the event happens.
9 * @param thisArgs The 'this' which will be used when calling the event listener.
10 * @param disposables An array to which a {{IDisposable}} will be added.
11 * @return
12 */
13 (listener: (e: T) => any, thisArgs?: any, disposables?: Disposable[]): Disposable;
14}
15export declare namespace Event {
16 const None: Event<any>;
17}
18export interface EmitterOptions {
19 onFirstListenerAdd?: Function;
20 onLastListenerRemove?: Function;
21}
22export declare class Emitter<T> {
23 private _options?;
24 private static _noop;
25 private _event;
26 private _callbacks;
27 constructor(_options?: EmitterOptions | undefined);
28 /**
29 * For the public to allow to subscribe
30 * to events from this Emitter
31 */
32 get event(): Event<T>;
33 /**
34 * To be kept private to fire an event to
35 * subscribers
36 */
37 fire(event: T): any;
38 dispose(): void;
39}