Nodejs(4) - 事件

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

//注册some event 事件
event.on('some_event',function(){

	console.log('some event occured.');
});

setTimeout(function(){
//发送一个some_event 事件
event.emit('some_event');
},1000);

你可能感兴趣的:(js,node,event)