Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.