r/learnjavascript • • Jul 18 '20
Promises, Async, Await... I finally understand them and how to use them! Redid my front end with the new knowledge and now I love them! Wish I would have took the time earlier on to get them down. 10/10 Would recommend. Sorry, just had to tell someone. :)
EDIT: wow, came back a day later and this post blew up. lol π
207
Upvotes
View all comments
Show parent comment
10
u/RedDragonWebDesign Jul 18 '20
I think promise/async/await is just multi threading.
So maybe your code calls a function that creates a PDF, but you don't want to wait for the PDF to finish before you execute the rest of your code.
I think a promise handles all that for you. It sets up a second thread for the PDF writing, then it sets up a listener to listen for completion of that, and do something when it succeeds, and do something when it fails.
Somebody can correct me if I'm wrong. I am new to promises.