What is an EventEmitter?

Node.js modules, files and async · Freshers and experienced

Model answer

EventEmitter from node:events lets objects emit named events and others listen: emitter.on('done', fn) and emitter.emit('done', data). Many Node classes (streams, servers) use it. Always handle the special 'error' event, because an unhandled one throws and can crash the process.

Learn this topic

Async JavaScript in Node: Promises, async/await and the Event Loop in the course Node.js and Express: Build a Back End API from Scratch.

Sign in to add your own answer.

More questions