You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The section points out that this code has inconsistent behavior, since the getData() method's if clause, unlike the else clause, is synchronous. But, again, the problem is that getData() 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:
Why it is necessary to manually ensure correct ordering on conditional use of promises.
In particular, why it might be necessary to explicitly introduce asynchronicity into an execution path that would ordinarily be entirely synchronous.
Why microtasks are the right way to do the things mentioned above, and therefore why microtasks have legitimate uses.
Do you have any supporting links, references, or citations?
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: