Re: [whatwg/dom] Consider adding AbortController.prototype.follow(signal) (#920)

@domenic 
> I tried to link to a couple examples of that, where you want to create a new AbortSignal from two other AbortSignals. It's not obvious to me how to do that from a single follow like you describe.

I think `new AbortController(...signals)` is actually very simple to `CancelToken.race` API in that the construction is at the creation. For example the first example is:

```js
const ac1 = new AbortController();
const ac2 = new AbortController();

const combined = new AbortController(ac1.signal, ac2.signal);
```

Though in this case, since there is a hierarchy you don't actually usually create 3 sources but two.

I think doing this on the signal and not controller can work though having users write:

```js
const parent = new AbortController();
const child = new AbortController();
// ...
action(AbortSignal.race(parent.signal, child.signal));

const parent = new AbortController();
// child controller
const child = new AbortController(parent.signal);
// ...
action(child.signal);
```

Is a bit more code and doesn't establish hierarchy between the parent/child controllers (which may be desireable?).

-- 
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-727162295

Received on Saturday, 14 November 2020 07:48:10 UTC