Skip to content

Commit

Permalink
Introduce AbortSignal.timeout()
Browse files Browse the repository at this point in the history
Closes #951.
  • Loading branch information
domenic authored Feb 2, 2022
1 parent 16a01dd commit db4088a
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions dom.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1771,6 +1771,7 @@ to <a for=AbortSignal>signal abort</a> on <a>this</a>'s <a for=AbortController>s
[Exposed=*]
interface AbortSignal : EventTarget {
[NewObject] static AbortSignal abort(optional any reason);
[NewObject] static AbortSignal timeout([EnforceRange] unsigned long long milliseconds);

readonly attribute boolean aborted;
readonly attribute any reason;
Expand All @@ -1784,6 +1785,11 @@ interface AbortSignal : EventTarget {
<dd>Returns an {{AbortSignal}} instance whose <a for=AbortSignal>abort reason</a> is set to
<var>reason</var> if not undefined; otherwise to an "{{AbortError!!exception}}" {{DOMException}}.

<dt><code>AbortSignal . <a method for=AbortSignal lt=timeout(milliseconds)>timeout</a>(<var>milliseconds</var>)</code>
<dd>Returns an {{AbortSignal}} instance which will be aborted in <var>milliseconds</var>
milliseconds. Its <a for=AbortSignal>abort reason</a> will be set to a
"{{TimeoutError!!exception}}" {{DOMException}}.

<dt><code><var>signal</var> . <a attribute for=AbortSignal>aborted</a></code>
<dd>Returns true if <var>signal</var>'s {{AbortController}} has signaled to abort; otherwise false.

Expand Down Expand Up @@ -1836,6 +1842,31 @@ are:
<li>Return <var>signal</var>.
</ol>

<p>The static <dfn method for=AbortSignal><code>timeout(<var>milliseconds</var>)</code></dfn> method
steps are:

<ol>
<li><p>Let <var>signal</var> be a new {{AbortSignal}} object.

<li><p>Let <var>global</var> be <var>signal</var>'s <a>relevant global object</a>.

<li>
<p><a>Run steps after a timeout</a> given <var>global</var>, "<code>AbortSignal-timeout</code>",
<var>milliseconds</var>, and the following step:</p>

<ol>
<li><p><a>Queue a global task</a> on the <a>timer task source</a> given <var>global</var> to
<a for=AbortSignal>signal abort</a> given <var>signal</var> and a new
"{{TimeoutError!!exception}}" {{DOMException}}.
</ol>

<p>For the duration of this timeout, if <var>signal</var> has any event listeners registered for
its {{AbortSignal/abort}} event, there must be a strong reference from <var>global</var> to
<var>signal</var>.

<li><p>Return <var>signal</var>.
</ol>

<p>The <dfn attribute for=AbortSignal>aborted</dfn> getter steps are to return true if <a>this</a>
is [=AbortSignal/aborted=]; otherwise false.

Expand Down

0 comments on commit db4088a

Please sign in to comment.