var events = require(‘events‘);var eventEmitter=new events.EventEmitter();eventEmitter.on(‘speak‘,function (msg) { console.log(msg+‘: speak‘);})eventEmitter.emit(‘speak‘,‘huchao‘);
Node js eventEmitter
原文:http://www.cnblogs.com/huchaoheng/p/7770516.html