You are here: Home / Topics / Event Types in Node Js

Event Types in Node Js

Filed under: NodeJs on 2024-02-22 21:01:23
Sr.No.Events & Description
1newListener
1. event − String: the event name
2. listener − Function: the event handler function
This event is emitted any time a listener is added. When this event is triggered, the listener may not yet have been added to the array of listeners for the event.
2removeListener
1. event − String The event name
2. listener − Function The event handler function
This event is emitted any time someone removes a listener.
When this event is triggered, the listener may not yet have been
removed from the array of listeners for the event.

emitter.removeListener(event, listener)
Remove a listener from the listener array for the specified event. 

Caution:
changes array indices in the listener array behind the listener.


var callback = function(stream) {
console.log('someone connected!');
};
server.on('connection', callback);
server.removeListener('connection', callback);
emitter.removeAllListeners([event])


Removes all listeners, or those of the specified event.

About Author:
T
Team MCQ Buddy     View Profile
Hi, I am using MCQ Buddy. I love to share content on this website.