![Node.js event emitter cheat sheet](/sites/default/files/styles/cheat_sheet_feature/public/nodejs-event-emitters_cover_1x.png?itok=cTW68hIG)
![Node.js event emitter cheat sheet](/sites/default/files/styles/cheat_sheet_feature/public/nodejs-event-emitters_cover_1x.png?itok=cTW68hIG)
About
Event Emitters are one of the most important built-in APIs since much of Node.js' core is built around an idiomatic asynchronous event-driven architecture. Event Emitters can help developers create a publisher-subscriber pattern with ease. After reading this cheat sheet, the readers will have a better understanding of how to:
- Create an event-emitter instance
- Emitting events
- Listening for events
- Handling multiple events
- Configuring event emitters
Excerpt
EventEmitter.prototype.setMaxListeners()
Sets the maximum allowed listeners for a specific event. Node.js will print a warning if more than 10 listeners are added for a specific event. setMaxListeners
allows you to modify this limit.
myEmitter.setMaxListeners(25);