Skip to content

Commit caa295f

Browse files
keithamuskoddsson
andcommitted
fix spelling and formatting
Co-authored-by: Kristján Oddsson <[email protected]>
1 parent a30e05f commit caa295f

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

learn/techniques/using-cancellation-signals.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,25 @@ which can be operated with an `AbortController`.
1111
The `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_
2121
changes. 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

2626
An `AbortSignal`s `.aborted` property will be `true` if the signal has been aborted - you can periodically check that to
2727
stop any work that is about to be done. `AbortSignal` is also an `EventTarget` - it emits an `abort` event which you can
2828
listen to and invoke your tear down.
2929

3030
You 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
9292
A 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
9494
different methods.
9595
9696
```js
@@ -125,11 +125,11 @@ class StopWatchElement extends HTMLElement {
125125
## Combining multiple Cancellation Signals
126126
127127
It'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
129129
using `AbortSignal.any()`, which creates a _new signal_ that aborts when any of the given _cancellation signals_ abort.
130130
It'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
133133
passed via `start({ signal })`. Making use of internal and external _cancellation signals_, with `AbortSignal.any()`:
134134
135135
```js

0 commit comments

Comments
 (0)