Re: [whatwg/dom] AbortController.prototype.timeout and AbortController.prototype.cancel (Issue #1039)

`close()` definitely works over `cancel()`

And I could get on board with `follow` with the exception that it's not much better/different than simply attaching an event listener to the signal.

```js
class TimeoutAbortController extends AbortController {
  #timer;

  static #abort() { this.abort(this.#timer.reason); }

  timeout(delay) {
    this.#timer = AbortSignal.timeout(delay);
    this.#timer.addEventListener('abort', this.#abort, { once: true });
  }

  close() {
    this.#timer?.removeEventListener('abort', this.#abort);
    this.#timer = undefined;
    super.close();
  }
}
```

`close()` here is still useful, but the `follow()` feels superfluous.

-- 
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/1039#issuecomment-987112406

Received on Monday, 6 December 2021 19:28:28 UTC