Skip to content

Commit

Permalink
events.markdown document improvements
Browse files Browse the repository at this point in the history
Improvements to events.markdown documentation per
nodejs#8853 (same fix as before but
rebased on joyent/v0.10
  • Loading branch information
jasnell committed Dec 19, 2014
1 parent 1b81ea8 commit f201640
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions doc/api/events.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ added and `'removeListener'` when a listener is removed.
### emitter.addListener(event, listener)
### emitter.on(event, listener)

Adds a listener to the end of the listeners array for the specified event.
Adds a listener to the end of the listeners array for the specified `event`.
No checks are made to see if the `listener` has already been added. Multiple
calls passing the same combination of `event` and `listener` will result
in the `listener` being added multiple times.

server.on('connection', function (stream) {
console.log('someone connected!');
Expand Down Expand Up @@ -65,6 +68,11 @@ Remove a listener from the listener array for the specified event.
// ...
server.removeListener('connection', callback);

`removeListener` will remove, at most, one instance of a listener from the
listener array. If any single listener has been added multiple times to the
listener array for the specified `event`, then `removeListener` must be called
multiple times to remove each instance.

Returns emitter, so calls can be chained.

### emitter.removeAllListeners([event])
Expand Down Expand Up @@ -110,8 +118,8 @@ Return the number of listeners for a given event.
* `event` {String} The event name
* `listener` {Function} The event handler function

This event is emitted any time someone adds a new listener. It is unspecified
if `listener` is in the list returned by `emitter.listeners(event)`.
This event is emitted any time a listener is added. When this event is triggered,
the listener may not yet have been added to the array of listeners for the `event`.


### Event: 'removeListener'
Expand Down

0 comments on commit f201640

Please sign in to comment.