Skip to content

Commit 2977839

Browse files
benjamingrevanlucas
authored andcommittedMar 31, 2016
doc: use consistent event name parameter
Implementing the suggestion in #4554 this pull request renames the parameter name in all the places that accept an event name as a parameter. Previously, the parameter has been called `event` or `type`. Now as suggested it is consistently called `eventName`. PR-URL: #5850 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
1 parent 949b17f commit 2977839

File tree

1 file changed

+31
-29
lines changed

1 file changed

+31
-29
lines changed
 

‎doc/api/events.markdown

+31-29
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ added and `'removeListener'` when a listener is removed.
201201

202202
### Event: 'newListener'
203203

204-
* `event` {String|Symbol} The event name
204+
* `eventName` {String|Symbol} The name of the event being listened for
205205
* `listener` {Function} The event handler function
206206

207207
The `EventEmitter` instance will emit it's own `'newListener'` event *before*
@@ -237,16 +237,16 @@ myEmitter.emit('event');
237237

238238
### Event: 'removeListener'
239239

240-
* `event` {String|Symbol} The event name
240+
* `eventName` {String|Symbol} The event name
241241
* `listener` {Function} The event handler function
242242

243243
The `'removeListener'` event is emitted *after* a listener is removed.
244244

245-
### EventEmitter.listenerCount(emitter, event)
245+
### EventEmitter.listenerCount(emitter, eventName)
246246

247247
Stability: 0 - Deprecated: Use [`emitter.listenerCount()`][] instead.
248248

249-
A class method that returns the number of listeners for the given `event`
249+
A class method that returns the number of listeners for the given `eventName`
250250
registered on the given `emitter`.
251251

252252
```js
@@ -284,32 +284,33 @@ emitter.once('event', () => {
284284
});
285285
```
286286

287-
### emitter.addListener(event, listener)
287+
### emitter.addListener(eventName, listener)
288288

289-
Alias for `emitter.on(event, listener)`.
289+
Alias for `emitter.on(eventName, listener)`.
290290

291-
### emitter.emit(event[, arg1][, arg2][, ...])
291+
### emitter.emit(eventName[, arg1][, arg2][, ...])
292292

293-
Synchronously calls each of the listeners registered for `event`, in the order
294-
they were registered, passing the supplied arguments to each.
293+
Synchronously calls each of the listeners registered for the event named
294+
`eventName`, in the order they were registered, passing the supplied arguments
295+
to each.
295296

296-
Returns `true` if event had listeners, `false` otherwise.
297+
Returns `true` if the event had listeners, `false` otherwise.
297298

298299
### emitter.getMaxListeners()
299300

300301
Returns the current max listener value for the `EventEmitter` which is either
301302
set by [`emitter.setMaxListeners(n)`][] or defaults to
302303
[`EventEmitter.defaultMaxListeners`][].
303304

304-
### emitter.listenerCount(event)
305+
### emitter.listenerCount(eventName)
305306

306-
* `event` {Value} The type of event
307+
* `eventName` {Value} The name of the event being listened for
307308

308-
Returns the number of listeners listening to the `event` type.
309+
Returns the number of listeners listening to the event named `eventName`.
309310

310-
### emitter.listeners(event)
311+
### emitter.listeners(eventName)
311312

312-
Returns a copy of the array of listeners for the specified `event`.
313+
Returns a copy of the array of listeners for the event named `eventName`.
313314

314315
```js
315316
server.on('connection', (stream) => {
@@ -319,12 +320,12 @@ console.log(util.inspect(server.listeners('connection')));
319320
// Prints: [ [Function] ]
320321
```
321322

322-
### emitter.on(event, listener)
323+
### emitter.on(eventName, listener)
323324

324325
Adds the `listener` function to the end of the listeners array for the
325-
specified `event`. No checks are made to see if the `listener` has already
326-
been added. Multiple calls passing the same combination of `event` and
327-
`listener` will result in the `listener` being added, and called, multiple
326+
event named `eventName`. No checks are made to see if the `listener` has
327+
already been added. Multiple calls passing the same combination of `eventName`
328+
and `listener` will result in the `listener` being added, and called, multiple
328329
times.
329330

330331
```js
@@ -335,10 +336,11 @@ server.on('connection', (stream) => {
335336

336337
Returns a reference to the `EventEmitter` so calls can be chained.
337338

338-
### emitter.once(event, listener)
339+
### emitter.once(eventName, listener)
339340

340-
Adds a **one time** `listener` function for the `event`. This listener is
341-
invoked only the next time `event` is triggered, after which it is removed.
341+
Adds a **one time** `listener` function for the event named `eventName`. This
342+
listener is invoked only the next time `eventName` is triggered, after which
343+
it is removed.
342344

343345
```js
344346
server.once('connection', (stream) => {
@@ -348,20 +350,20 @@ server.once('connection', (stream) => {
348350

349351
Returns a reference to the `EventEmitter` so calls can be chained.
350352

351-
### emitter.removeAllListeners([event])
353+
### emitter.removeAllListeners([eventName])
352354

353-
Removes all listeners, or those of the specified `event`.
355+
Removes all listeners, or those of the specified `eventName`.
354356

355357
Note that it is bad practice to remove listeners added elsewhere in the code,
356358
particularly when the `EventEmitter` instance was created by some other
357359
component or module (e.g. sockets or file streams).
358360

359361
Returns a reference to the `EventEmitter` so calls can be chained.
360362

361-
### emitter.removeListener(event, listener)
363+
### emitter.removeListener(eventName, listener)
362364

363-
Removes the specified `listener` from the listener array for the specified
364-
`event`.
365+
Removes the specified `listener` from the listener array for the event named
366+
`eventName`.
365367

366368
```js
367369
var callback = (stream) => {
@@ -374,8 +376,8 @@ server.removeListener('connection', callback);
374376

375377
`removeListener` will remove, at most, one instance of a listener from the
376378
listener array. If any single listener has been added multiple times to the
377-
listener array for the specified `event`, then `removeListener` must be called
378-
multiple times to remove each instance.
379+
listener array for the specified `eventName`, then `removeListener` must be
380+
called multiple times to remove each instance.
379381

380382
Note that once an event has been emitted, all listeners attached to it at the
381383
time of emitting will be called in order. This implies that any `removeListener()`

0 commit comments

Comments
 (0)
Please sign in to comment.