Web
Analytics
event emitters node js | example - Tutorial

For Consultation : +91 9887575540

Stay Connected :

What is Event and Event Emitter in Node JS

  • An User Action i.e click
  • Event names are defined simply by calling .emit with the event name.
  • An object sends events using the .emit function.
  • Events are sent to any listeners that have registered to receive events from the object.
  • The program registers to receive an event by calling that object’s .on method, giving the event name and an event handler function.

How to Send Data using Emit Method

  • it is required to send data along with an event. To do so, simply add the data as arguments to the .emit call
  • this.emit(‘eventName’, data1, data2, ..);





 

Example

Output

Node JS event emitter example





Select your currency