Ensuring ordering on conditional use of promises: Example is fundamentally flawed #33581
Labels
Content:WebAPI
Web API docs
needs triage
Triage needed by staff and/or partners. Automatically applied when an issue is opened.
MDN URL
https://developer.mozilla.org/en-US/docs/Web/API/HTML_DOM_API/Microtask_guide
What specific section or headline is this issue about?
Ensuring ordering on conditional use of promises
What information was incorrect, unhelpful, or incomplete?
That section contains this example:
This example seems to be fundamentally flawed for two reasons:
else
clause is asynchronous, but thegetData()
method has a signature implying it is synchronous.this
in an arrow function.But item 1 above is the real problem. The section continues with another example:
The section points out that this code has inconsistent behavior, since the
getData()
method'sif
clause, unlike theelse
clause, is synchronous. But, again, the problem is thatgetData()
is treated as synchronous when it is actually asynchronous!The section then points out a supposed fix: instead of having just one clause of
getData()
contradict its signature by being asynchronous, make both clauses contradict its signature by being asynchronous! This makes no sense; all it does is make the code even harder to reason about, and it does nothing to explain how microtasks have a legitimate use.What did you expect to see?
I expected to see an explanation of:
Do you have any supporting links, references, or citations?
No response
Do you have anything more you want to share?
No response
MDN metadata
Page report details
en-us/web/api/html_dom_api/microtask_guide
The text was updated successfully, but these errors were encountered: