Closed
Description
https://dom.spec.whatwg.org/#abortsignal-signal-abort
Currently the order is:
- If signal’s aborted flag is set, then return.
- Set signal’s aborted flag.
- For each algorithm in signal’s abort algorithms: run algorithm.
- Empty signal’s abort algorithms.
- Fire an event named abort at signal.
If you want to create a new signal that copies another signal, you do something like this:
- Let originalSignal be a signal we got from somewhere.
- Let signal be a new
AbortSignal
. - Add the following steps to originalSignal:
- Signal abort on signal.
- Return signal.
A side effect of this, is the "abort" event will despatch on signal before originalSignal.
const controller = new AbortController();
const signal = controller.signal;
const request = new Request('.', {signal});
const requestClone = request.clone(); // this copies the signal as above.
request.signal.addEventListener('abort', () => console.log('original'));
requestClone.signal.addEventListener('abort', () => console.log('clone'));
controller.abort();
In the code above, "clone" is logged before "original". Is this a problem?
Metadata
Metadata
Assignees
Labels
No labels