Skip to content

Commit

Permalink
doc: fix EventEmitter examples
Browse files Browse the repository at this point in the history
Since the section refers to EventEmitter, instances in the example
should be created of the same class EventEmitter.

PR-URL: #33513
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
shaw91 authored and aduh95 committed Oct 16, 2020
1 parent 7f25fe8 commit 9e5a27a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion doc/api/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ but important side effect: any *additional* listeners registered to the same
listener that is in the process of being added.

```js
class MyEmitter extends EventEmitter {}

const myEmitter = new MyEmitter();
// Only do this once so we don't loop forever
myEmitter.once('newListener', (event, listener) => {
Expand Down Expand Up @@ -319,7 +321,7 @@ A class method that returns the number of listeners for the given `eventName`
registered on the given `emitter`.

```js
const myEmitter = new MyEmitter();
const myEmitter = new EventEmitter();
myEmitter.on('event', () => {});
myEmitter.on('event', () => {});
console.log(EventEmitter.listenerCount(myEmitter, 'event'));
Expand Down

0 comments on commit 9e5a27a

Please sign in to comment.