Skip to content

Commit 98de4f4

Browse files
authored
Merge pull request #2386 from RapTho/patch-2
Typos + rephrasing
2 parents 02089cf + 7b21346 commit 98de4f4

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

5-network/04-fetch-abort/article.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ When `abort()` is called:
2525
- `controller.signal.aborted` property becomes `true`.
2626

2727
Generally, we have two parties in the process:
28-
1. The one that performs an cancelable operation, it sets a listener on `controller.signal`.
28+
1. The one that performs a cancelable operation, it sets a listener on `controller.signal`.
2929
2. The one that cancels: it calls `controller.abort()` when needed.
3030

3131
Here's the full example (without `fetch` yet):
@@ -35,7 +35,7 @@ let controller = new AbortController();
3535
let signal = controller.signal;
3636

3737
// The party that performs a cancelable operation
38-
// gets "signal" object
38+
// gets the "signal" object
3939
// and sets the listener to trigger when controller.abort() is called
4040
signal.addEventListener('abort', () => alert("abort!"));
4141

@@ -46,15 +46,15 @@ controller.abort(); // abort!
4646
alert(signal.aborted); // true
4747
```
4848

49-
As we can see, `AbortController` is just a means to pass `abort` events when `abort()` is called on it.
49+
As we can see, `AbortController` is just a mean to pass `abort` events when `abort()` is called on it.
5050

51-
We could implement same kind of event listening in our code on our own, without `AbortController` object at all.
51+
We could implement the same kind of event listening in our code on our own, without the `AbortController` object.
5252

53-
But what's valuable is that `fetch` knows how to work with `AbortController` object, it's integrated with it.
53+
But what's valuable is that `fetch` knows how to work with the `AbortController` object. It's integrated in it.
5454

5555
## Using with fetch
5656

57-
To become able to cancel `fetch`, pass the `signal` property of an `AbortController` as a `fetch` option:
57+
To be able to cancel `fetch`, pass the `signal` property of an `AbortController` as a `fetch` option:
5858

5959
```js
6060
let controller = new AbortController();
@@ -97,7 +97,7 @@ try {
9797

9898
## AbortController is scalable
9999

100-
`AbortController` is scalable, it allows to cancel multiple fetches at once.
100+
`AbortController` is scalable. It allows to cancel multiple fetches at once.
101101

102102
Here's a sketch of code that fetches many `urls` in parallel, and uses a single controller to abort them all:
103103

@@ -113,7 +113,7 @@ let fetchJobs = urls.map(url => fetch(url, {
113113

114114
let results = await Promise.all(fetchJobs);
115115

116-
// if controller.abort() is called from elsewhere,
116+
// if controller.abort() is called from anywhere,
117117
// it aborts all fetches
118118
```
119119

@@ -137,12 +137,12 @@ let fetchJobs = urls.map(url => fetch(url, { // fetches
137137
// Wait for fetches and our task in parallel
138138
let results = await Promise.all([...fetchJobs, ourJob]);
139139

140-
// if controller.abort() is called from elsewhere,
140+
// if controller.abort() is called from anywhere,
141141
// it aborts all fetches and ourJob
142142
```
143143

144144
## Summary
145145

146-
- `AbortController` is a simple object that generates `abort` event on it's `signal` property when `abort()` method is called (and also sets `signal.aborted` to `true`).
147-
- `fetch` integrates with it: we pass `signal` property as the option, and then `fetch` listens to it, so it becomes possible to abort the `fetch`.
146+
- `AbortController` is a simple object that generates an `abort` event on it's `signal` property when the `abort()` method is called (and also sets `signal.aborted` to `true`).
147+
- `fetch` integrates with it: we pass the `signal` property as the option, and then `fetch` listens to it, so it's possible to abort the `fetch`.
148148
- We can use `AbortController` in our code. The "call `abort()`" -> "listen to `abort` event" interaction is simple and universal. We can use it even without `fetch`.

0 commit comments

Comments
 (0)