mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
doc: fix events.once()
example using AbortSignal
PR-URL: https://github.com/nodejs/node/pull/55144 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
This commit is contained in:
parent
1d38bd1122
commit
755b89772d
@ -1459,8 +1459,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!
|
||||
ac.abort(); // Prints: Waiting for the event was canceled!
|
||||
```
|
||||
|
||||
```cjs
|
||||
@ -1483,8 +1482,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!
|
||||
ac.abort(); // Prints: Waiting for the event was canceled!
|
||||
```
|
||||
|
||||
### Awaiting multiple events emitted on `process.nextTick()`
|
||||
|
Loading…
Reference in New Issue
Block a user