paste-markdown icon indicating copy to clipboard operation
paste-markdown copied to clipboard

feat: add support for AbortSignal

Open keithamus opened this issue 3 years ago • 0 comments

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 avatar Oct 26 '21 16:10 keithamus