emitter.eventNames()
Returns
an array listing the events for which the emitter has registered listeners.
HelloWorld.js
var EventEmitter = require('events').EventEmitter; var emitter = new EventEmitter(); emitter.on("welcome", (name) => { console.log("Hello Mr.%s", name); }); emitter.on("morning", (firstName, lastName) => { console.log("Good Morning Mr.%s %s", firstName, lastName); }); console.log(emitter.eventNames());
Output
[
'welcome', 'morning' ]
No comments:
Post a Comment