-
Notifications
You must be signed in to change notification settings - Fork 22.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add AbortSignal.any #27424
Add AbortSignal.any #27424
Conversation
Preview URLs Flaws (2)URL:
URL:
(comment last updated: 2023-11-18 05:22:22) |
@Jamesernator MDN document things once there is a browser with an release implementation - existence in a specification is not enough. Do you know of a browser that supports this? The reason the specifications and browser compatibility are not working is that there is no front matter key like:
The browser compatibility data needs to be updated with the same key and data for the supported browser versions: https://github.com/mdn/browser-compat-data/blob/main/api/AbortSignal.json |
Ah yes this is new in Chrome Dev, admittedly I assumed it was already shipping in browsers as Node has already shipped it. Oh well, this will be ready when that branch of Chrome become stable in a month or so. |
@Jamesernator Actually it being in node/deno is good enough to justify doing the docs, but we should also do the browser compatibility data too. |
This pull request has merge conflicts that must be resolved before it can be merged. |
This pull request has merge conflicts that must be resolved before it can be merged. |
Hi @Jamesernator - just dropping a note that there are some merge conflicts that need to be resolved here if you'd like to come back to this. notes:
|
The merge conflict is resolved, I've also added the compat data in a PR to browser-compat-data. |
the issue #30095 suggest this contribute, maybe it is a good idea to add a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few details and this is good to go. Good job!
signal: combinedSignal, | ||
}); | ||
const body = await res.blob(); | ||
// do something with downloaded content |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// do something with downloaded content | |
// Do something with downloaded content: | |
// … |
@@ -24,6 +24,8 @@ _The AbortSignal interface may also inherit properties from its parent interface | |||
|
|||
- {{domxref("AbortSignal/abort_static", "AbortSignal.abort()")}} | |||
- : Returns an **`AbortSignal`** instance that is already set as aborted. | |||
- {{domxref("AbortSignal.any()")}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- {{domxref("AbortSignal.any()")}} | |
- {{domxref("AbortSignal/any_static", "AbortSignal.any()")}} |
|
||
### Using AbortSignal.any() | ||
|
||
This example demonstrates combining both a signal from an {{domxref("AbortController")}}, and a timeout signal from {{domxref("AbortSignal.timeout")}}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example demonstrates combining both a signal from an {{domxref("AbortController")}}, and a timeout signal from {{domxref("AbortSignal.timeout")}}. | |
This example demonstrates combining both a signal from an {{domxref("AbortController")}}, and a timeout signal from {{domxref("AbortSignal/timeout_static", "AbortSignal.timeout")}}. |
I have added the "Fixes #xyz" in the description. |
|
||
### Return value | ||
|
||
An `AbortSignal` instance with the {{domxref("AbortSignal.aborted")}} property set to `true`, and {{domxref("AbortSignal.reason")}} set to the specified or default reason value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An `AbortSignal` instance with the {{domxref("AbortSignal.aborted")}} property set to `true`, and {{domxref("AbortSignal.reason")}} set to the specified or default reason value. | |
An `AbortSignal` instance with the {{domxref("AbortSignal.reason", "reason")}} property set to the specified or default reason value. |
note that AbortSignal.aborted
should initial to be false
, only when any of the passing signals
is already aborted, the AbortSignal.aborted
will be true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this section is was nonsense, I copied AbortSignal.abort
as a template and forgot to change this section.
I've updated this section to be similar to Promise.any instead.
|
||
## Examples | ||
|
||
### Using AbortSignal.any() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
### Using AbortSignal.any() | |
### Using `AbortSignal.any()` |
const button = document.getElementById("cancelDownloadButton"); | ||
|
||
const userCancelController = new AbortController(); | ||
cancelDownloadButton.addEventListener("click", () => { | ||
userCancelController.abort(); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const button = document.getElementById("cancelDownloadButton"); | |
const userCancelController = new AbortController(); | |
cancelDownloadButton.addEventListener("click", () => { | |
userCancelController.abort(); | |
}); | |
const cancelDownloadButton = document.getElementById("cancelDownloadButton"); | |
const userCancelController = new AbortController(); | |
cancelDownloadButton.addEventListener("click", () => { | |
userCancelController.abort(); | |
}); |
the button
should be cancelDownloadButton
Just a usage suggestion to Github, when others give a review, you can click the also, you can go to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Description
This adds MDN docs for the AbortSignal.any.
Motivation
This is a new API.
Additional details
Spec is here. A change has been made to an example on the main
AbortSignal
page also.Note
I'm unsure of where to add the relevant
{{Specifications}}
link. Checking the page the local server just shows{{Specifications}}
where the specifications box should be (other pages seem to work fine).Fixes #30095