Skip to content

Replace uninstall with abortcontroller#29

Merged
keithamus merged 7 commits intomainfrom
replace-uninstall-with-abortcontroller
Nov 3, 2021
Merged

Replace uninstall with abortcontroller#29
keithamus merged 7 commits intomainfrom
replace-uninstall-with-abortcontroller

Conversation

@keithamus
Copy link
Copy Markdown
Contributor

What?

This PR removes subscribe/unsubscribe and also uninstall in favour of one single interface: install(container, { signal }). signal is an AbortSignal which can be triggered to invoke the same behaviour uninstall did.

We also drop "support" for Edge 18 in this PR.

This should be considered a breaking change.

Why?

I think the commits explain each decision quite nicely, but to quote:

Subscribe is useful in a world where Observables move forward, but that looks somewhat unlikely, and it's a fairly un-idiomatic pattern outside of Observables. There are better mechanisms for this. If someone needs to wrap this library in an Observable, install/uninstall can be wrapped directly.

[Using AbortSignal] drastically reduces the amount of complex state we need to keep track of just to unbind event listeners.

[Allowing] users calling the install() method to supply their own signal negates the need for uninstall(), as aborting the given signal has the same effect.

khiga8 and others added 6 commits November 2, 2021 13:54
Edge 18 is quite old and no longer supported on GitHub.com.
Additionally, using User Agent sniffing is not a robust way to handle
this. Should this be needed, it could be moved upstream, as it really
overloads the `quoteMarkdown` option.

Co-authored-by: Keith Cirkel <keithamus@users.noreply.github.com>
BREAKING CHANGE

Subscribe is useful in a world where Observables move forward, but that
looks somewhat unlikely, and it's a fairly un-idiomatic pattern outside
of Observables. There are better mechanisms for this. If someone needs
to wrap this library in an Observable, install/uninstall can be wrapped
directly.

Co-authored-by: Keith Cirkel <keithamus@users.noreply.github.com>
This drastically reduces the amount of complex state we need to keep
track of just to unbind event listeners.

Co-authored-by: Kate Higa <khiga8@github.com>
This reduces the need for fetching options from a WeakMap which is
side-effectful, allowing these methods to be called without a prior
`install()` call.

Co-authored-by: Kate Higa <khiga8@github.com>
This allows users calling the `install()` method to supply their own
`signal`, which negates the need for `uninstall()`, as aborting the
given signal has the same effect.

Co-authored-by: Kate Higa <khiga8@github.com>
BREAKING CHANGE

Now we have an exposed `signal` option, we can simply use this to
provide a way for users to "uninstall" these event listeners.
`uninstall` is no longer needed.

Co-authored-by: Keith Cirkel <keithamus@users.noreply.github.com>
@keithamus keithamus requested a review from a team as a code owner November 2, 2021 17:07
Comment thread src/index.ts
Comment thread src/index.ts
Copy link
Copy Markdown
Member

@srt32 srt32 left a comment

Choose a reason for hiding this comment

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

👨‍🍳

@keithamus keithamus merged commit 5e8689f into main Nov 3, 2021
@keithamus keithamus deleted the replace-uninstall-with-abortcontroller branch November 3, 2021 08:55
This was referenced Nov 3, 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.

3 participants