Closed lukasolson closed 3 years ago
@mo Do you agree with this assessment? I can throw together a PR for this as well.
@lukasolson yup, it's a bug in the polyfill. A PR for this would be great.
I came here to say this. For my use case, this is unusable because it's inaccurate. The important part of the abort signal is that is synchronously tears down whatever it is supposed to tear down.
So FWIW: I started trying to build a PR for this repository, but it seemed like I was rewriting most of the implementation here, it didn't seem like this repo was actively maintained, and I had need of an AbortSignal that properly dispatched events, so I made a new package here:
https://www.npmjs.com/package/yet-another-abortcontroller-polyfill
I hope this helps someone else that finds this stale issue.
fixed by ambar in the latest version
I've got the following snippet of code:
When I run this in Chrome, I get the following output:
But when I run this using this polyfill, I get the following:
It looks like this is because the events handlers are debounced. If I were to use
signal.onAbort = ...
it would behave the same as Chrome, but I'd rather use theaddEventListener
handler as it avoids directly mutatingsignal
.