Skip to content

Add support for abort signals when calling on and once#26

Merged
pleek91 merged 4 commits intomainfrom
abort-signal-support
Feb 16, 2025
Merged

Add support for abort signals when calling on and once#26
pleek91 merged 4 commits intomainfrom
abort-signal-support

Conversation

@pleek91
Copy link
Copy Markdown
Collaborator

@pleek91 pleek91 commented Feb 16, 2025

Description

When stopping event handlers its often useful to be able to stop multiple listeners at the same time. By adding support for abort signals multiple handlers can be stopped at once without having to call multiple off callbacks.

const controller = new AbortController()

emitter.on(globalHandler, { signal: controller.signal })
emitter.on('eventOne', eventOneHandler, { signal: controller.signal })
emitter.on('eventTwo', eventTwoHandler, { signal: controller.signal })

controller.abort()

Note: I also organized some test coverage and added some missing test cases to unify testing around on, once, and next`

@netlify
Copy link
Copy Markdown

netlify bot commented Feb 16, 2025

Deploy Preview for kitbag-events ready!

Name Link
🔨 Latest commit c05c2be
🔍 Latest deploy log https://app.netlify.com/sites/kitbag-events/deploys/67b26db0057c7f000889274f
😎 Deploy Preview https://deploy-preview-26--kitbag-events.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Copy Markdown
Contributor

@stackoverfloweth stackoverfloweth left a comment

Choose a reason for hiding this comment

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

very nice 👏

got a few small code suggestions but nothing I feel super strongly about

pleek91 and others added 3 commits February 16, 2025 16:51
Co-authored-by: Evan Sutherland <stackoverfloweth@gmail.com>
Co-authored-by: Evan Sutherland <stackoverfloweth@gmail.com>
Co-authored-by: Evan Sutherland <stackoverfloweth@gmail.com>
@pleek91 pleek91 merged commit 0c1f753 into main Feb 16, 2025
6 checks passed
@pleek91 pleek91 deleted the abort-signal-support branch February 17, 2025 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants