- From: Mattias Buelens <notifications@github.com>
- Date: Fri, 13 Nov 2020 03:52:43 -0800
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Friday, 13 November 2020 11:52:55 UTC
Indeed, it's easy enough to do in userland, and I'm totally fine with keeping it there: ```javascript function followSignal(followingAbortController, parentSignal) { // 1. If followingSignal’s aborted flag is set, then return. if (followingAbortController.aborted) { return; } // 2. If parentSignal’s aborted flag is set, then signal abort on followingSignal. if (parentSignal.aborted) { followingAbortController.abort(); return; } // 3. Otherwise, add the following abort steps to parentSignal: const onAbort = () => { // 3.1. Signal abort on followingSignal. followingAbortController.abort(); }; parentSignal.addEventListener('abort', onAbort, { once: true }); // Non-standard: if followingSignal becomes aborted for some other reason, // remove the abort steps from the parentSignal. followingAbortController.signal.addEventListener('abort', () => { parentSignal.removeEventListener('abort', onAbort); }); } ``` That said, I wouldn't mind having this exposed as `AbortController.prototype.follow(signal)` if there's enough interest. 🙂 -- 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/920#issuecomment-726722960
Received on Friday, 13 November 2020 11:52:55 UTC