1 | import { Disposable, DisposableGroup } from './disposable';
|
2 | import { MaybePromise } from './types';
|
3 |
|
4 |
|
5 |
|
6 | export interface Event<T> {
|
7 | |
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | (listener: (e: T) => any, thisArgs?: any, disposables?: DisposableGroup): Disposable;
|
15 | }
|
16 | export declare namespace Event {
|
17 | function getMaxListeners(event: Event<unknown>): number;
|
18 | function setMaxListeners<N extends number>(event: Event<unknown>, maxListeners: N): N;
|
19 | function addMaxListeners(event: Event<unknown>, add: number): number;
|
20 | const None: Event<any>;
|
21 | |
22 |
|
23 |
|
24 |
|
25 | function map<I, O>(event: Event<I>, mapFunc: (i: I) => O): Event<O>;
|
26 | }
|
27 | declare type Callback = (...args: any[]) => any;
|
28 | declare class CallbackList implements Iterable<Callback> {
|
29 | private _callbacks;
|
30 | private _contexts;
|
31 | get length(): number;
|
32 | add(callback: Function, context?: any, bucket?: Disposable[]): void;
|
33 | remove(callback: Function, context?: any): void;
|
34 | [Symbol.iterator](): IterableIterator<(...args: any[]) => any>;
|
35 | invoke(...args: any[]): any[];
|
36 | isEmpty(): boolean;
|
37 | dispose(): void;
|
38 | }
|
39 | export interface EmitterOptions {
|
40 | onFirstListenerAdd?: Function;
|
41 | onLastListenerRemove?: Function;
|
42 | }
|
43 | export declare class Emitter<T = any> {
|
44 | private _options?;
|
45 | private static LEAK_WARNING_THRESHHOLD;
|
46 | private static _noop;
|
47 | private _event;
|
48 | protected _callbacks: CallbackList | undefined;
|
49 | private _disposed;
|
50 | private _leakingStacks;
|
51 | private _leakWarnCountdown;
|
52 | constructor(_options?: EmitterOptions | undefined);
|
53 | /**
|
54 | * For the public to allow to subscribe
|
55 | * to events from this Emitter
|
56 | */
|
57 | get event(): Event<T>;
|
58 | protected checkMaxListeners(maxListeners: number): (() => void) | undefined;
|
59 | protected pushLeakingStack(): () => void;
|
60 | protected popLeakingStack(stack: string): void;
|
61 | /**
|
62 | * To be kept private to fire an event to
|
63 | * subscribers
|
64 | */
|
65 | fire(event: T): any;
|
66 | /**
|
67 | * Process each listener one by one.
|
68 | * Return `false` to stop iterating over the listeners, `true` to continue.
|
69 | */
|
70 | sequence(processor: (listener: (e: T) => any) => MaybePromise<boolean>): Promise<void>;
|
71 | dispose(): void;
|
72 | }
|
73 | export declare type WaitUntilData<T> = Omit<T, 'waitUntil' | 'token'>;
|
74 | export interface WaitUntilEvent {
|
75 | |
76 |
|
77 |
|
78 | token: CancellationToken;
|
79 | |
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 | waitUntil(thenable: Promise<any>): void;
|
87 | }
|
88 | export declare namespace WaitUntilEvent {
|
89 | |
90 |
|
91 |
|
92 |
|
93 |
|
94 | function fire<T extends WaitUntilEvent>(emitter: Emitter<T>, event: WaitUntilData<T>, timeout?: number, token?: CancellationToken): Promise<void>;
|
95 | }
|
96 | import { CancellationToken } from './cancellation';
|
97 | export declare class AsyncEmitter<T extends WaitUntilEvent> extends Emitter<T> {
|
98 | protected deliveryQueue: Promise<void> | undefined;
|
99 | |
100 |
|
101 |
|
102 | fire(event: WaitUntilData<T>, token?: CancellationToken, promiseJoin?: (p: Promise<any>, listener: Function) => Promise<any>): Promise<void>;
|
103 | protected deliver(listeners: Callback[], event: WaitUntilData<T>, token: CancellationToken, promiseJoin?: (p: Promise<any>, listener: Function) => Promise<any>): Promise<void>;
|
104 | }
|
105 | export {};
|
106 |
|
\ | No newline at end of file |