File tree Expand file tree Collapse file tree 1 file changed +4
-0
lines changed
Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -1909,6 +1909,8 @@ const { addAbortListener } = require('node:events');
19091909
19101910function example (signal ) {
19111911 signal .addEventListener (' abort' , (e ) => e .stopImmediatePropagation ());
1912+ // addAbortListener() returns a disposable, so the `using` keyword ensures
1913+ // the abort listener is automatically removed when this scope exits.
19121914 using _ = addAbortListener (signal, (e ) => {
19131915 // Do something when signal is aborted.
19141916 });
@@ -1920,6 +1922,8 @@ import { addAbortListener } from 'node:events';
19201922
19211923function example (signal ) {
19221924 signal .addEventListener (' abort' , (e ) => e .stopImmediatePropagation ());
1925+ // addAbortListener() returns a disposable, so the `using` keyword ensures
1926+ // the abort listener is automatically removed when this scope exits.
19231927 using _ = addAbortListener (signal, (e ) => {
19241928 // Do something when signal is aborted.
19251929 });
You can’t perform that action at this time.
0 commit comments