@@ -11,25 +11,25 @@ which can be operated with an `AbortController`.
1111The ` AbortController ` & ` AbortSignal ` APIs can help manage operational "life time". Some examples:
1212
1313- Long running or asynchronous tasks, for example timers or network fetches
14- - Overlapping operations, for example cancelling in-flight network fetches to replace them with newer ones
14+ - Overlapping operations, for example canceling in-flight network fetches to replace them with newer ones
1515- Set up and tear down, for example a Web Components ` connectedCallback ` and ` disconnectedCallback `
1616
1717## AbortSignal AbortController Pattern
1818
1919_ Cancellation Signals_ get given to APIs so they know when to abort. An ` AbortSignal ` is created by a _ controller_
2020(` new AbortSignal() ` will throw an error). _ Controllers_ allow you to make the decision of when a _ Cancellation Signal_
2121changes. Creating an ` AbortController ` will also create a new ` AbortSignal ` , accessible via ` .signal ` . Code that has
22- access to the _ controller_ can determine when it should be aborted (by calling ` .abort() ` ), while code that has access
23- to the _ signal_ can be notified of the abort. To make a new ` AbortController ` , call ` new AbortContoller() ` . The
24- constructor takes no arguments.
22+ access to the _ controller_ can decide when it should be aborted (by calling ` .abort() ` ), while code that has access to
23+ the _ signal_ can be notified of the abort. To make a new ` AbortController ` , call ` new AbortContoller() ` . The constructor
24+ takes no arguments.
2525
2626An ` AbortSignal ` s ` .aborted ` property will be ` true ` if the signal has been aborted - you can periodically check that to
2727stop any work that is about to be done. ` AbortSignal ` is also an ` EventTarget ` - it emits an ` abort ` event which you can
2828listen to and invoke your tear down.
2929
3030You can also create some basic _ controller-free signals_ that follow some common patterns. For example
31- ` AbortSignal.timeout(1000) ` will create a _ cancellation signal_ that aborts after 1000ms . These _ controller-free
32- signals_ cannot be manually aborted. However, you can _ combine_ controller-free and controllable signals with
31+ ` AbortSignal.timeout(1000) ` will create a _ cancellation signal_ that aborts after 1000 milliseconds . These
32+ _ controller-free signals_ cannot be manually aborted. You can _ combine_ controller-free and controllable signals with
3333` AbortSignal.any([...signals]) ` .
3434
3535## Using Cancellation Signals internally manage your private APIs
@@ -85,12 +85,12 @@ class StopWatchElement extends HTMLElement {
8585
8686## Using Cancellation Signals in your own public APIs
8787
88- If you can use a signal as part of your internal state, it might be simpler to provide it as part of the public API. If
89- you are considering using _cancellation signals_ in a public API, it's a good idea to make them an optional part of your
90- API as they won't always be _needed_.
88+ If you can use a signal as part of your internal state, it might be simpler to add it as part of the public API. If you
89+ are considering using _cancellation signals_ in a public API, it's a good idea to make them an optional part of your API
90+ as they won't always be _needed_.
9191
9292A component using _cancellation signals_ no longer needs separate start & stop methods, instead combining into one and
93- relying on the signal to know when to stop. This can often simplify code as there is no need to track state across
93+ relying on the signal to know when to stop. This can often simplify code as there's no need to track state across
9494different methods.
9595
9696` ` ` js
@@ -125,11 +125,11 @@ class StopWatchElement extends HTMLElement {
125125## Combining multiple Cancellation Signals
126126
127127It's possible to combine multiple sources of _cancellation signals_ - for example combining internal and external
128- _cancellation signals_ to allow for multiple flavors of API. Two or more _cancellation signals_ can be combined into one
128+ _cancellation signals_ to allow for multiple flavors of API. Two or more _cancellation signals_ can be joined into one
129129using ` AbortSignal .any ()` , which creates a _new signal_ that aborts when any of the given _cancellation signals_ abort.
130130It's similar to ` Promise .any ()` , but for ` AbortSignal` .
131131
132- A component can provide the more traditional ` start ()` and ` stop ()` APIs, as well allowing _cancellation signals_ to be
132+ A component can offer the more traditional ` start ()` and ` stop ()` APIs, as well allowing _cancellation signals_ to be
133133passed via ` start ({ signal })` . Making use of internal and external _cancellation signals_, with ` AbortSignal .any ()` :
134134
135135` ` ` js
0 commit comments