forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fbemitter.d.ts
71 lines (55 loc) · 2.24 KB
/
fbemitter.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Type definitions for Facebook's EventEmitter 2.0.0
// Project: https://github.com/facebook/emitter
// Definitions by: kmxz <https://github.com/kmxz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace FBEmitter {
export class EventSubscription {
listener: Function;
context: any;
/**
* Removes this subscription from the subscriber that controls it.
*/
remove(): void;
}
export class EventEmitter {
constructor();
/**
* Adds a listener to be invoked when events of the specified type are
* emitted. An optional calling context may be provided. The data arguments
* emitted will be passed to the listener function.
*/
addListener(eventType: string, listener: Function, context?: any): EventSubscription;
/**
* Similar to addListener, except that the listener is removed after it is
* invoked once.
*/
once(eventType: string, listener: Function, context?: any): EventSubscription;
/**
* Removes all of the registered listeners, including those registered as
* listener maps.
*/
removeAllListeners(eventType?: string): void;
/**
* Provides an API that can be called during an eventing cycle to remove the
* last listener that was invoked. This allows a developer to provide an event
* object that can remove the listener (or listener map) during the
* invocation.
*
* If it is called when not inside of an emitting cycle it will throw.
*/
removeCurrentListener(): void;
/**
* Returns an array of listeners that are currently registered for the given
* event.
*/
listeners(eventType: string): Function[];
/**
* Emits an event of the given type with the given data. All handlers of that
* particular type will be notified.
*/
emit(eventType: string, ...data: any[]): void;
}
}
declare module 'fbemitter' {
export = FBEmitter;
}