Saturday 6 May 2017

Not able to get the registered event name from event emitter using eventNames function in Nodejs

I am trying to get the registered event names from event emitter by using eventNames function but it is throwing TypeError: eventEmitter.eventNames is not a function error.

node -v is v4.2.6

var event = require("events").EventEmitter;

var eventEmitter = new event();

eventEmitter.on('test',function(){
    console.log("Hello!!!");

});

console.log("Event Names : "+eventEmitter.eventNames());

eventEmitter.emit('test');



via Prabu

No comments:

Post a Comment