Skip to main content

Nodejs Events

Events in Node.js


The EventEmitter Object

  • You can assign event handlers to your own events with the EventEmitter object.
  • In the example below we have created a function that will be executed when a "scream" event is fired.
  • To fire an event, use the emit() method.



var events = require('events');
var eventEmitter = new events.EventEmitter(); 

//Create an event handler: 
var myEventHandler = function () { 
 console.log('I hear a scream!'); 


//Assign the event handler to an event:

eventEmitter.on('scream', myEventHandler); 

//Fire the 'scream' event: 
eventEmitter.emit('scream');

Comments

Popular posts from this blog

Micro Loan Banking Management System

What is Google Adwords Certification Program

What is Google Adwords Certification Program? Google Certification Program is a program through which an individual can earn one of the most valuable status of being a google adwords qualified individual or a company can earn a google adwords certified partner status. Google Adwords Certification wiil show your knowledge, skills and proficiency in google adwords latest tools and it will show that an individual or a company know how to design, implement and manage an adwords campaign and they will use best practices and techniques and follow google adwords policies and guidelines which is one of the most important thing in eyes of Google. Google has launched two types of certification program for Adwords: Individual Qualification. Company Certification. Individual Qualification Individuals who want to add more value to there resume or an individual who want learn google adwords and get certified can study and get Google Adwords Qualified Individual also known as Google Adwo

My Second Awarded Project : skilled based social network