var EventEmitter = require('events').EventEmitter; //this is included in node
var util = require('util'); //this is included in node as well
var myObject = function(){
EventEmitter.call(this);
};
util.inherits(myObject, EventEmitter);
myObject.prototype.doSomething = function(thing){
this.emit('something', thing);
return this; //make your method chainable, for ease of use
};
var obj = new myObject;
obj.on('something', function(thing){
console.log(thing);
});
obj.doSomething('eat').doSomething('sleep').doSomething('code');