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
I think the comment // start doing something that could take a while is misleading:
functionfoo(x){// start doing something that could take a while// construct and return a promisereturnnewPromise(function(resolve,reject){// eventually, call `resolve(..)` or `reject(..)`,// which are the resolution callbacks for// the promise.});}
If I understood correctly the async code should be inside the function passed to the Promise, no? So the following would be more accurate:
functionfoo(x){// construct and return a promisereturnnewPromise(function(resolve,reject){// start doing something that could take a while// then foo returns the newly created Promise// eventually, call `resolve(..)` or `reject(..)`,// which are the resolution callbacks for// the promise.});}
The text was updated successfully, but these errors were encountered:
There are various reasons you want to "extract" the resolve capability as my snippet showed. I'm only pointing out that it's orthogonal/irrelevant how the actual promise resolving logic ends up getting handled.
The following code snippet is from Async & Performance Chapter 3.
I think the comment
// start doing something that could take a while
is misleading:If I understood correctly the async code should be inside the function passed to the Promise, no? So the following would be more accurate:
The text was updated successfully, but these errors were encountered: