Skip to content
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

Merged
merged 5 commits into from
Nov 20, 2023
Merged

Add AbortSignal.any #27424

merged 5 commits into from
Nov 20, 2023

Conversation

Jamesernator
Copy link
Contributor

@Jamesernator Jamesernator commented Jun 20, 2023

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

@Jamesernator Jamesernator requested review from a team as code owners June 20, 2023 00:59
@Jamesernator Jamesernator requested review from Elchi3 and removed request for a team June 20, 2023 00:59
@github-actions github-actions bot added the Content:WebAPI Web API docs label Jun 20, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jun 20, 2023

Preview URLs

Flaws (2)

URL: /en-US/docs/Web/API/AbortSignal
Title: AbortSignal
Flaw count: 1

  • macros:
    • /en-US/docs/Web/API/AbortSignal/any redirects to /en-US/docs/Web/API/AbortSignal/any_static

URL: /en-US/docs/Web/API/AbortSignal/any_static
Title: AbortSignal: any() static method
Flaw count: 1

  • bad_bcd_queries:
    • No BCD data for query: api.AbortSignal.any_static

(comment last updated: 2023-11-18 05:22:22)

@hamishwillee
Copy link
Collaborator

@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:

browser-compat: api.AbortSignal.any_static

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

@Elchi3 Elchi3 removed their request for review June 20, 2023 14:07
@Jamesernator
Copy link
Contributor Author

Jamesernator commented Jun 24, 2023

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.

@hamishwillee
Copy link
Collaborator

@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.

@github-actions github-actions bot added the merge conflicts 🚧 [PR only] label Jul 18, 2023
@github-actions
Copy link
Contributor

This pull request has merge conflicts that must be resolved before it can be merged.

@github-actions github-actions bot added merge conflicts 🚧 [PR only] and removed merge conflicts 🚧 [PR only] labels Jul 20, 2023
@github-actions
Copy link
Contributor

This pull request has merge conflicts that must be resolved before it can be merged.

@bsmth
Copy link
Member

bsmth commented Aug 29, 2023

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:

@Jamesernator
Copy link
Contributor Author

The merge conflict is resolved, I've also added the compat data in a PR to browser-compat-data.

@skyclouds2001
Copy link
Contributor

the issue #30095 suggest this contribute, maybe it is a good idea to add a fixes to the issue?

Copy link
Contributor

@teoli2003 teoli2003 left a 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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()")}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- {{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")}}.
Copy link
Contributor

@teoli2003 teoli2003 Nov 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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")}}.

@teoli2003
Copy link
Contributor

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Contributor Author

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()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Using AbortSignal.any()
### Using `AbortSignal.any()`

Comment on lines 35 to 40
const button = document.getElementById("cancelDownloadButton");

const userCancelController = new AbortController();
cancelDownloadButton.addEventListener("click", () => {
userCancelController.abort();
});
Copy link
Contributor

@skyclouds2001 skyclouds2001 Nov 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

@skyclouds2001
Copy link
Contributor

Just a usage suggestion to Github, when others give a review, you can click the commit suggestion button to directly commit the review to your pull request, rather then do the commit yourself instead

image

also, you can go to the files panel and use the add suggestion to batch button to merge multpile reviews in a single commit

Copy link
Contributor

@teoli2003 teoli2003 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@teoli2003 teoli2003 merged commit cac5497 into mdn:main Nov 20, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:WebAPI Web API docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The AbortSignal.any static method not documented
5 participants