![]() The function that executes upon the firing of the event is called the event-listener or observer function. However, in case of an event, they are fired upon the completion of some task. The difference lies between them is that the callback function is called when the async function returns the results. This process is called the event loop.Ĭallback and event both work to provide a better experience and concurrent responses to the requests. Whenever the Node server starts, it initializes the variables, declares functions, and then goes into the state where it waits for events. Node JS is known as an event-driven programming language therefore, it is very fast and concurrent as compared to the other technologies. What is event driven programming in Node JS? After the completion of the task, the event is fired which tells the event listener to execute. ![]() Whenever an async function is called, Node JS keeps an event that loops until a task completes. ![]() ![]() Although Node JS is a single-threaded application, every API in Node JS maintains asynchronous behavior using async function calls and hence, maintains concurrency.īasically, the event works with the callbacks. Node JS provides concurrency by using the callbacks and events. This article is in the continuation of the previous and relates events with the event loop, so if you have not gone through the callback concept, it is recommended to grip on the concept first. We learned the callback concept of Node JS in the previous tutorial. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |