Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2020-09-01 05:36:20 +0300
committerRich Trott <rtrott@gmail.com>2020-09-03 15:29:06 +0300
commitf9c362ff6c4fad4cf67df5a94ba5fdb9321a3d2b (patch)
treea08fd17ab05d6d73b793d2bcc2d3dcab55db8fda /doc/api/events.md
parent69b8a394237aeffc4af951ce099e98ef6a2e4dd2 (diff)
doc: revise AbortSignal text and example using events.once()
Add a line to the example code to clarify what happens if an event is emitted after listening is canceled. Make minor revisions to surrounding text. PR-URL: https://github.com/nodejs/node/pull/35005 Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'doc/api/events.md')
-rw-r--r--doc/api/events.md6
1 files changed, 3 insertions, 3 deletions
diff --git a/doc/api/events.md b/doc/api/events.md
index 387b9b15df1..92535b1fde4 100644
--- a/doc/api/events.md
+++ b/doc/api/events.md
@@ -835,8 +835,7 @@ added:
* `emitter` {EventEmitter}
* `name` {string}
* `options` {Object}
- * `signal` {AbortSignal} An {AbortSignal} that may be used to cancel waiting
- for the event.
+ * `signal` {AbortSignal} Can be used to cancel waiting for the event.
* Returns: {Promise}
Creates a `Promise` that is fulfilled when the `EventEmitter` emits the given
@@ -895,7 +894,7 @@ ee.emit('error', new Error('boom'));
// Prints: ok boom
```
-An {AbortSignal} may be used to cancel waiting for the event early:
+An {AbortSignal} can be used to cancel waiting for the event:
```js
const { EventEmitter, once } = require('events');
@@ -918,6 +917,7 @@ async function foo(emitter, event, signal) {
foo(ee, 'foo', ac.signal);
ac.abort(); // Abort waiting for the event
+ee.emit('foo'); // Prints: Waiting for the event was canceled!
```
### Awaiting multiple events emitted on `process.nextTick()`