@@ -33,7 +33,10 @@ added and `'removeListener'` when a listener is removed.
33
33
### emitter.addListener(event, listener)
34
34
### emitter.on(event, listener)
35
35
36
- Adds a listener to the end of the listeners array for the specified event.
36
+ Adds a listener to the end of the listeners array for the specified ` event ` .
37
+ No checks are made to see if the ` listener ` has already been added. Multiple
38
+ calls passing the same combination of ` event ` and ` listener ` will result in the
39
+ ` listener ` being added multiple times.
37
40
38
41
server.on('connection', function (stream) {
39
42
console.log('someone connected!');
@@ -65,6 +68,11 @@ Remove a listener from the listener array for the specified event.
65
68
// ...
66
69
server.removeListener('connection', callback);
67
70
71
+ ` removeListener ` will remove, at most, one instance of a listener from the
72
+ listener array. If any single listener has been added multiple times to the
73
+ listener array for the specified ` event ` , then ` removeListener ` must be called
74
+ multiple times to remove each instance.
75
+
68
76
Returns emitter, so calls can be chained.
69
77
70
78
### emitter.removeAllListeners([ event] )
@@ -110,14 +118,14 @@ Return the number of listeners for a given event.
110
118
* ` event ` {String} The event name
111
119
* ` listener ` {Function} The event handler function
112
120
113
- This event is emitted any time someone adds a new listener. It is unspecified
114
- if ` listener ` is in the list returned by ` emitter.listeners( event) ` .
121
+ This event is emitted any time a listener is added. When this event is triggered,
122
+ the listener may not yet have been added to the array of listeners for the ` event ` .
115
123
116
124
117
125
### Event: 'removeListener'
118
126
119
127
* ` event ` {String} The event name
120
128
* ` listener ` {Function} The event handler function
121
129
122
- This event is emitted any time someone removes a listener. It is unspecified
123
- if ` listener ` is in the list returned by ` emitter.listeners( event) ` .
130
+ This event is emitted any time someone removes a listener. When this event is triggered,
131
+ the listener may not yet have been removed from the array of listeners for the ` event ` .
0 commit comments