Node.js events create EventEmitter

Description

Node.js events create EventEmitter


var EventEmitter = require("events").EventEmitter;

var event = new EventEmitter();
event.on("some_event", function(){
    console.log("some_event");
});//w ww .ja  v a2 s  . co  m

setTimeout(function(){
    event.emit("some_event");
}, 1000);



PreviousNext

Related