- From: bojavou <notifications@github.com>
- Date: Tue, 04 Jul 2023 18:08:11 -0700
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/issues/1082/1620880641@github.com>
I feel like there are cases where you want feedback to affect related operations. Give up on a set of operations if nothing returns in time, otherwise they're still relevant so keep them all running. ```js const signal = AbortSignal.timeout(5000, { cancelable: true }) // Calculations detect a cancelable signal, // cancel to keep the whole set running on first returned value const stream = new CombineStream([ generateNumbers(startFrom, Type.PrimeNumbers, { signal }), generateNumbers(startFrom, Type.SurrealNumbers, { signal }), generateNumbers(startFrom, Type.VampireNumbers, { signal }) ]) ``` Run 3 requests to the same server and keep them all alive as long as anything is returning data. ```js const signal = AbortSignal.timeout(5000, { resettable: true }) // fetch detects a resettable signal, // and keeps it refreshed from all requests const datasets = Promise.all([ fetch('/WesternRegion.json', { signal }) .then(response => response.json()), fetch('/EasternRegion.json', { signal }) .then(response => response.json()), fetch('/SouthernRegion.json', { signal }) .then(response => response.json()) ]) ``` It's really important not to make signals consumer-mutable by default. But where the operations are related, and you can guarantee the signal will never go to anything else, this is something I could use. -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/dom/issues/1082#issuecomment-1620880641 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/dom/issues/1082/1620880641@github.com>
Received on Wednesday, 5 July 2023 01:08:17 UTC