doc: document return values of EventEmitter methods

This commit is contained in:
Sam Roberts 2013-04-30 15:24:48 -07:00 committed by Ben Noordhuis
parent 0e21d7b985
commit 41cbdc5e64

View File

@ -39,6 +39,8 @@ Adds a listener to the end of the listeners array for the specified event.
console.log('someone connected!'); console.log('someone connected!');
}); });
Returns emitter, so calls can be chained.
### emitter.once(event, listener) ### emitter.once(event, listener)
Adds a **one time** listener for the event. This listener is Adds a **one time** listener for the event. This listener is
@ -49,6 +51,8 @@ it is removed.
console.log('Ah, we have our first user!'); console.log('Ah, we have our first user!');
}); });
Returns emitter, so calls can be chained.
### emitter.removeListener(event, listener) ### emitter.removeListener(event, listener)
Remove a listener from the listener array for the specified event. Remove a listener from the listener array for the specified event.
@ -61,11 +65,13 @@ Remove a listener from the listener array for the specified event.
// ... // ...
server.removeListener('connection', callback); server.removeListener('connection', callback);
Returns emitter, so calls can be chained.
### emitter.removeAllListeners([event]) ### emitter.removeAllListeners([event])
Removes all listeners, or those of the specified event. Removes all listeners, or those of the specified event.
Returns emitter, so calls can be chained.
### emitter.setMaxListeners(n) ### emitter.setMaxListeners(n)
@ -89,6 +95,8 @@ Returns an array of listeners for the specified event.
Execute each of the listeners in order with the supplied arguments. Execute each of the listeners in order with the supplied arguments.
Returns `true` if event had listeners, `false` otherwise.
### Class Method: EventEmitter.listenerCount(emitter, event) ### Class Method: EventEmitter.listenerCount(emitter, event)