commit
75680eef5c
1 changed files with 2 additions and 2 deletions
|
@ -9,7 +9,7 @@ The usage is very straightforward:
|
||||||
|
|
||||||
## The AbortController object
|
## The AbortController object
|
||||||
|
|
||||||
Step 1: create a controller:
|
Create a controller:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let controller = new AbortController();
|
let controller = new AbortController();
|
||||||
|
@ -145,4 +145,4 @@ let results = await Promise.all([...fetchJobs, ourJob]);
|
||||||
|
|
||||||
- `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`).
|
- `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`).
|
||||||
- `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`.
|
- `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`.
|
||||||
- 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`.
|
- 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`.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue