Event-Driven Architecture
Events are one of the most powerful ways to use Node.js. Node.js was designed from the ground up to build event-driven modules. Many core libraries offer an events interface that can be used and extended easily. Also, Node.js provides a powerful events library that can be used to build event-driven modules.
In this chapter, we delve into events in Node.js. We will learn how to use events from the core libraries, from event listener registration to event emission, and handling multiple listeners for the same event.
We will build our first HTTP server using events, and we will discuss the organization of event listeners and the cleanup.
To sum up, here are the main topics that we will explore in this chapter:
- Introducing events
- Watching for file changes
- The Node.js event emitter library
- Your first HTTP server
- Adding an event layer to your modules
By the end of this chapter, you will know how to use events and even how...