28
loading...
This website collects cookies to deliver better user experience
you
are the main controller
, each type of food
is a different function
and the waiter
is a 3rd party API
call or a database
process. In asynchronous code, the controller keeps moving to the next possible step to execute, anytime it is free. Like if you have 2 bites from the pizza slice, and then have some tacos, then get back & continue the pizza where you left off. The eating of tacos does not need the whole pizza to be over, it just needs your mouth to have a pause in between eating pizza.What are promises in Nodejs ?
How does Nodejs handle so many concurrent requests ?
How to avoid blocking the event loop in Nodejs ?
How to make Nodejs functions non-blocking ?
How to use async and await in Nodejs ?
How to run cpu-intensive functions in Nodejs ?
Why did the chicken cross the road? to fulfill a nodejs promise..wait..sorry that one doesn't belong here..oops..getting back to our topic
you clean the fishbowl as expected
maybe some problem (error) occurs, and you are not able to complete the cleaning...let's assume the bowl broke.
friend
is the main controller
and you
are the function
that is called which returns a 'promise'. The controller just holds onto the promise and then goes about doing other tasks. It comes back to the promise when it gets a response regarding the status of the promise : resolved or rejected. This status update is referred to as the promise getting 'settled'. then / catch
async await