Nodejs 事件注入

事件类型hook. 可以在指定的地方去注入或执行

var EventEmitter = require('events').EventEmitter;
var util = require('util');

var User = function(username){
    this.username = username;
}
util.inherits(User, EventEmitter);
var user = new User('Xiukun');
user.on('nuevent', function(props){
    console.log(props);
});
user.emit('nuevent', 'dancing');