Skip to content

doc: simplify addAbortListener example#61842

Open
atlowChemi wants to merge 1 commit intonodejs:mainfrom
atlowChemi:use-the-using-keyword
Open

doc: simplify addAbortListener example#61842
atlowChemi wants to merge 1 commit intonodejs:mainfrom
atlowChemi:use-the-using-keyword

Conversation

@atlowChemi
Copy link
Member

The example was written before v8 supported the using keyword and hence explicitly called Symbol.dispose.

Since now the keyword is supported, the example can be simplified.

@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. events Issues and PRs related to the events subsystem / EventEmitter. labels Feb 15, 2026
@atlowChemi atlowChemi force-pushed the use-the-using-keyword branch from a82b1f5 to 83dbc3e Compare February 15, 2026 21:31
The example was written before v8 supported the using keyword
and hence explicitly called Symbol.dispose

Since now the keyword is supported, the example can be simplified
@atlowChemi atlowChemi force-pushed the use-the-using-keyword branch from 83dbc3e to b6097b8 Compare February 15, 2026 21:37
Comment on lines +1912 to +1914
using _ = addAbortListener(signal, (e) => {
// Do something when signal is aborted.
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be worth adding a comment underneath to state that the abort listener is automatically removed when leaving the scope, otherwise the significance of the using statement doesn't have any immediate context to the casual observer.

@Renegade334 Renegade334 added dont-land-on-v20.x PRs that should not land on the v20.x-staging branch and should not be released in v20.x. dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. labels Feb 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Issues and PRs related to the documentations. dont-land-on-v20.x PRs that should not land on the v20.x-staging branch and should not be released in v20.x. dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. events Issues and PRs related to the events subsystem / EventEmitter.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants