Skip to content

Commit 53aab29

Browse files
committed
fixup: add #on example
1 parent db52004 commit 53aab29

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

doc/api/events.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,9 +598,13 @@ logFnWrapper.listener();
598598
// logs "log once" to the console and removes the listener
599599
logFnWrapper();
600600

601-
// will return an empty array
601+
emitter.on('log', () => console.log('log persistently'));
602+
// will return a new Array with a single function bound by `on` above
602603
const newListeners = emitter.rawListeners('log');
603-
assert.strictEqual(newListeners.length, 0);
604+
605+
// logs "log persistently" twice
606+
newListeners[0]();
607+
emitter.emit('log');
604608
```
605609

606610
[`--trace-warnings`]: cli.html#cli_trace_warnings

0 commit comments

Comments
 (0)