Quantcast
Channel: Comments on Promises and Static Values
Browsing latest articles
Browse All 9 View Live

By: Teddy

If the function is async, shouldn’t it automatically wrap any return value in a promise?

View Article



By: Gordon Smith

Also that cache “pattern” has a race condition if its called twice in quick succession (it may end up calling the server twice) as there is a window of opportunity during the “await” for the server...

View Article

By: TIm

Isn’t async function always returning a promise?

View Article

By: Sam

Is there any difference between this syntax and Promise.resolve or, in an aync function, just returning the value?

View Article

By: Jan Jaap

Actually, the last function does not need to return Promises… It’s declared as async which means whatever you return will become a promise… So you could simplify it as: // Async function that returns...

View Article


By: Wésley Queiroz

I am pretty sure that when we are declaring an async function we do not need to return a new Promise. If the function is not declared as an async function the example would be precise. But as we...

View Article

By: Travis

I tend to wrap my entire promise-returning functions in one new Promise. In my mind, it reduces confusion. The example code you gave becomes something like this: async function getInfo(url) { return...

View Article

By: Ben C

You actually don’t need to do that, and nor should you, because that’s exactly what the async keyword does, so you’re just adding redundant complexity, which bloats code and is likely to lead to bugs,...

View Article


By: Wesley de A Queiroz

I totally agree with Ben C. All async functions are already wrapped at runtime in a promise. Their return value is passed to the resolve function and their throw value are passed to reject. Just...

View Article

Browsing latest articles
Browse All 9 View Live




Latest Images