From Callbacks to Promises to AsyncAwait
Single Threaded Node In spite of having a single threaded architecture, Node is not blocked while doing parallel operations. How does Node achieve this ? Even though Node is single threaded, it is event driven and makes use of background workers to complete the tasks. Tasks are pushed off to workers from the main thread. Main thread is not blocked and continues to listen to other requests. When the task is done, the result of the task(if any) is put back to the event loop for further processing which is accomplished by callback. In this write up, I will be discussing on the evolution of callbacks. The way they evolved to Promises and most recently to Async-Await. Event Loop is outside the scope of this topic, for which there are plenty of articles available online. CallBacks As I said before, callbacks are a means by which the background workers intimate the main thread of the completion of the asynchronous task they were performing. Initially when the task was invoked, w