Title: events: add addDisposableListener method to EventEmitter by jasnell · Pull Request #58453 · nodejs/node · GitHub
Open Graph Title: events: add addDisposableListener method to EventEmitter by jasnell · Pull Request #58453 · nodejs/node
X Title: events: add addDisposableListener method to EventEmitter by jasnell · Pull Request #58453 · nodejs/node
Description: This adds new use(...) and useOnce(...) methods addDisposableListener method to EventEmitter that returns a disposable object that will unregister the event listeners when disposed, along with two changes that use the new apis to demonstrate how it can be used to simplify some cleanup. const ee = new EventEmitter(); { using ds = new DisposableStack(); ds.use(ee.addDisposableListener('foo', () => {}); ds.use(ee.addDisposableListener('bar', () => {}); if (something) ds.use(ee.addDisposableListener('baz', () => {}); } // The event listeners will all be removed automatically when ds is disposed. // We don't need to separately remember to call removeListener/off to cleanup the event listeners
Open Graph Description: This adds new use(...) and useOnce(...) methods addDisposableListener method to EventEmitter that returns a disposable object that will unregister the event listeners when disposed, along with two ...
X Description: This adds new use(...) and useOnce(...) methods addDisposableListener method to EventEmitter that returns a disposable object that will unregister the event listeners when disposed, along with two ...
Opengraph URL: https://github.com/nodejs/node/pull/58453
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/commits/:range(.:format) |
| route-controller | pull_requests |
| route-action | commits |
| fetch-nonce | v2:94439838-ae74-2a5d-440e-6ec6669f7f9d |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | E89A:DAE6B:3517673:46747A3:6A655319 |
| html-safe-nonce | e244c13eef12a8f1b7ed1fef5ff024413141a26e5e4ee7dc11a7fb140f06f0a5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFODlBOkRBRTZCOjM1MTc2NzM6NDY3NDdBMzo2QTY1NTMxOSIsInZpc2l0b3JfaWQiOiI1NjcwNzk3ODg4NTIyMTEzODE3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 70de2cefa1cceee3c6fb389c64c47d6c15e7bdda4a04f7810fce1b6c5370b732 |
| hovercard-subject-tag | pull_request:2542590322 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b |
| twitter:image | https://avatars.githubusercontent.com/u/439929?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/439929?s=400&v=4 |
| og:image:alt | This adds new use(...) and useOnce(...) methods addDisposableListener method to EventEmitter that returns a disposable object that will unregister the event listeners when disposed, along with two ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 52c76df668885aaff23b50bdca1fa1ea44ac9c1553e888ebc70ff1e4daa4625b |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 309153364422b3c499922d1a2a6404910a58ed8e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width