Skip to content

Commit

Permalink
fixup AbortError and whitespace.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikewest committed Apr 6, 2017
1 parent 61c6e72 commit 9282bf3
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions dom.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1421,28 +1421,33 @@ can only be used to influence an ongoing one.

<h3 id=controlling-promises>Controlling {{Promise}}s</h3>

<p>Though {{Promise}} objects don't have any built-in cancellation mechanism, many
{{Promise}}-vending APIs require cancellation semantics. {{PromiseController}} is meant to support
these requirements by providing an {{PromiseController/abort()}} method that toggles the state of
a corresponding {{PromiseSignal}} object. The API which wishes to support cancelation can accept
such a {{PromiseSignal}}, and use its state to determine how (not) to proceed.
Though {{Promise}} objects don't have any built-in cancellation mechanism, many {{Promise}}-vending
APIs require cancellation semantics. {{PromiseController}} is meant to support these requirements by
providing an {{PromiseController/abort()}} method that toggles the state of a corresponding
{{PromiseSignal}} object. The API which wishes to support cancellation can accept such a
{{PromiseSignal}}, and use its state to determine how (not) to proceed.

Upon {{PromiseController/abort()}}, the relevant {{Promise}} will reject with an
<dfn exception>AbortError</dfn> [=simple exception=].

<div class=note>
For example, a hypothetical <code>DoAmazingness({ ... })</code> method could accept a
{{PromiseSignal}} object in order to support cancellation as follows:
For example, a hypothetical <code>DoAmazingness({ ... })</code> method could accept a
{{PromiseSignal}} object in order to support cancellation as follows:

<pre class=lang-javascript>
const controller = new PromiseController();
const signal = controller.signal;
DoAmazingness({ ..., signal }).then(result => ...);
const controller = new PromiseController();
const signal = controller.signal;
DoAmazingness({ ..., signal })
.then(result => ...)
.catch(e => ...);

...
...

controller.abort();
controller.abort();
</pre>

APIs that require more granular control could extend both {{PromiseController}} and
{{PromiseSignal}} according to their needs.
APIs that require more granular control could extend both {{PromiseController}} and
{{PromiseSignal}} according to their needs.
</div>

<h4 id=interface-promisecontroller>Interface {{PromiseController}}</h3>
Expand Down

0 comments on commit 9282bf3

Please sign in to comment.