re: Using Events In Node.js The Right Way VIEW POST

VIEW FULL DISCUSSION

May I ask a question, how do I fire a event?

Hey chenge, firing is just another word for "emitting".

Hi Usama thanks. But sendEmailOnRegistration doesn't work, why?

user = {};
myEmitter.emit('user-registered', user);

myEmitter.on('user-registered', (user) => {
  console.log("listened...");
});

myEmitter.on('user-registered', sendEmailOnRegistration);



I see. I must subscribe first.

code of conduct - report abuse