GeezerVison is showing github.com — doc: fix `events.once()` example using `AbortSignal` · nodejs/node@b963db9
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: doc/api/events.md +2-4Lines changed: 2 additions & 4 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1455,8 +1455,7 @@ async function foo(emitter, event, signal) { |
1455 | 1455 | } |
1456 | 1456 |
|
1457 | 1457 | foo(ee, 'foo', ac.signal); |
1458 | | -ac.abort(); // Abort waiting for the event |
1459 | | -ee.emit('foo'); // Prints: Waiting for the event was canceled! |
| 1458 | +ac.abort(); // Prints: Waiting for the event was canceled! |
1460 | 1459 | ``` |
1461 | 1460 |
|
1462 | 1461 | ```cjs |
@@ -1479,8 +1478,7 @@ async function foo(emitter, event, signal) { |
1479 | 1478 | } |
1480 | 1479 |
|
1481 | 1480 | foo(ee, 'foo', ac.signal); |
1482 | | -ac.abort(); // Abort waiting for the event |
1483 | | -ee.emit('foo'); // Prints: Waiting for the event was canceled! |
| 1481 | +ac.abort(); // Prints: Waiting for the event was canceled! |
1484 | 1482 | ``` |
1485 | 1483 |
|
1486 | 1484 | ### Awaiting multiple events emitted on `process.nextTick()` |
|