To listen to All Emitted Events in Node.js, we create our own Emitter
class.
For instance, we write
class Emitter extends require("events") {
emit(type, ...args) {
console.log(type + " emitted");
super.emit(type, ...args);
}
}
to create the Emitter
class that inherits from the events
constructor.
And we add our own emit
method to get the event type
and call super.emit
to emit the event.