Add and Remove EventEmitters in Node.js

InstructorWill Button

Share this video with your friends

Send Tweet

In this lesson, you will learn what an EventEmitter is and how it works. We start with a simple example creating an instance of the EventEmitter class, then expand on it by building listeners and emitting events to trigger them. You will learn how to view listeners in the global emitter object, as well as how to remove them and understand what the EventEmitter memory leak message means. We wrap everything up by examining the http server class to illustrate how node.js uses EventEmitters in many places for core features.

Sandeep Arneja
~ 6 years ago

I get undefined for global.emitter. Is this supposed to work in node version v8.9.4?

Sandeep Arneja
~ 6 years ago

never mind my comment above. in your case emitter is the name of your emitter and you added it via REPL, so it got put on the global namespace.