Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for AbortSignal #33

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

keithamus
Copy link
Member

To manage events, typically these projects have followed a pattern of using subscribe(): () => void where the returned function is the unsubscribe method. This gives us a more "ergonomic" mechanism for managing multiple event handlers, such that they can be quickly unbound.

This has worked fine, but it is a pattern we've developed in "user space" and so does not align with any spec. However, there is a spec which can help us here, which is AbortSignal. Events now support being given an AbortSignal which will unsubscribe the event when the signal is triggered.

https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#add_an_abortable_listener

This change adds {signal} as an option that can be passed to the install methods, which will be passed back to the event listeners.

@keithamus keithamus requested a review from a team as a code owner October 26, 2021 16:40
@keithamus keithamus requested review from koddsson and srt32 October 26, 2021 16:40
@ghost ghost deleted a comment Nov 10, 2021
@ghost ghost deleted a comment Nov 10, 2021
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