Core ModulesLesson 27Free preview
Events Module
This lesson is part of Node.js · All levels
Summary
The events module provides the EventEmitter class, the foundation of the event-driven pattern in Node.js. You can broadcast an event with a emitter and hear it on or once. Almost all of the asynchronous Node APIs, from streams to servers, are built on this pattern.
Key points
- EventEmitter adds an event with on and broadcasts it with emitter
- Once just executed the listener for the first call.
- Listeners run in sequence according to the registration order
- An event error without a listener could cause the process to crash.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.