- From: Jake Archibald <notifications@github.com>
- Date: Thu, 20 May 2021 05:38:46 -0700
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Thursday, 20 May 2021 12:38:59 UTC
> Do you find you need to "break out" with the `Promise` constructor as well? Very occasionally, but not often. The last time I remember doing it was to do the "abort the current operation in favour of a new operation" pattern before we had `AbortController`: ```js let currentJob = Promise.resolve(); let currentReject; function showSearchResults(input) { if (currentReject) currentReject(new DOMException('', 'AbortError')); const abortPromise = new Promise((_, reject) => { currentReject = reject; }); return currentJob = currentJob.catch(() => {}).then(() => { return Promise.race([ abortPromise, Promise.resolve().then(async () => { // …do stuff… }), ]); }); } ``` But I've since rewritten that code to just use `AbortController`. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/whatwg/dom/issues/981#issuecomment-845071876
Received on Thursday, 20 May 2021 12:38:59 UTC