UNPKG

chandnasujatha_shoppingexample

Version:

Demo for NodeJS

21 lines (16 loc) 538 B
var events = require('events'); var eve = new events.EventEmitter(); //Define your events.. eve.on('myevent',function(data){ console.log(data); console.log("Event called click is triggered") }) //your creating a event called click and a function to be invoked whrn the click happens //User will emitthis event //eve.emit('myevent','Test code from the emitter'); //fun called when event is triggered function callme() { console.log("I am called when event is triggered"); } eve.emit('myevent',callme);