Open utterances-bot opened 4 years ago
Very explanatory. Thank you and keep it up.
Thank You.
Wonderful article, thank you,
Nice
Great!
I'm reading your article and learning a lot! I have a quick question. A lot of my code has this:
return Promise.resolve()
.then(() => {
let objectFromDatabase = connectors.myTable.findOne({
where: {id: objectId}
});
return objectFromDatabase;
})
.catch((err) => {
console.log(err);
});
...this works fine. My question is, do I need to be doing:
return new Promise.resolve()
....instead of:
return Promise.resolve()
And if not, why not if I may ask? Thanks very much in advance for any thoughts / info!
Very good article, just need to know is which scenario to use promise and which to use async/await, Is promises used when multiple promises need to be checked using promise all, is there also a await all
What a detailed explanation, learned a-lot from it. thank you
This is a really well written article, I connected dots that I didn't know I needed to connect.
Thank you.
Great article. Congratulations!
Concise and informative.
Nice 👍
Nicely explained. Maybe little more explicit here in the Queue section:
but that it will add the anonymous function to the queue in that amount of time.
Web API will add this function to the queue (not directly from the stack)
Thank you so much for writing this. You're an incredibly teacher. :) I hope you keep writing about programming, even after you decide to retire. It's really helping me.
Good personal blog! Static site and commenting system works.
Thanks for this article. Can you please write a one for Closures?
@VikR0001
My question is, do I need to be doing:
return new Promise.resolve()
instead of:return Promise.resolve()
as Promise doc says, the resolve
method is static and you dont need to instantiate a new Promise to call it.
if you want to use Promise as object you can wrap functions that do not already support promises on Promise constructor:
const promise = new Promise( (res ,rej) => {
res("hello!")
} )
promise.then(val => console.log(val))
the console will show "hello!"
Great article. I was reading it for some days in order to understand everything!
Tania, thanks for the great article. I really enjoy your writing style. Simple with full of knowledge.
It was a great article finally I am able to clear confusion about .then and .catch.
Thanks for the great article. Some things didn't make sense right away, but I kept rereading and going through your examples until it clicked!
Thank you
I'm trying to use a promise or async/await to create a modal dialog API that returns information synchronously but I don't know how to un-stack the promise so that a click event triggers the resolution of the promise except by some kind of setTimeout(forever) hack. I want a simply synchronous api like:
// in the middle of some complex nested operation where callbacks just suck ... const btnText = await msgBox([ 'Yes', 'No', 'Maybe' ], 'Text of messagebox'); if (btnText == 'Maybe') { ....
Understanding the Event Loop, Callbacks, Promises, and Async/Await in JavaScript | Tania Rascia
This article was originally written for DigitalOcean. Introduction In the early days of the internet, websites often consisted of static…
https://www.taniarascia.com/asynchronous-javascript-event-loop-callbacks-promises-async-await/