// Create EventEmitter const events = require("events"); const eventsEmitter = new events.EventEmitter(); // Bind event handler const connectHandler = () => {console.log()'Connected is called! '); }; // Bind eventsemitter. on('connection', connectHandler); // Eventsemitter.emit ("connection");
console.log('Program completed');
Copy the code