Re: [whatwg/dom] Expose an `aborted` promise on AbortSignal? (#946)

I gave it a spin on squoosh.app, which uses abort signals quite a bit https://github.com/GoogleChromeLabs/squoosh/pull/954/files - it helped in one place!

The other helpers I needed were [`assetNotAborted`](https://github.com/whatwg/dom/issues/927), and a way to make a promise appear to be abortable. The implementation of the latter becomes:

```js
/**
 * Take a signal and promise, and returns a promise that rejects with an AbortError if the abort is
 * signalled, otherwise resolves with the promise.
 */
export async function abortable(signal, promise) {
  return abortableTask(signal, () => promise);
}
```

…which is kinda nice.

`abortableTask` is the wrong name though, since it clashes with tasks in HTML.

-- 
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/946#issuecomment-773998489

Received on Friday, 5 February 2021 12:17:42 UTC