Skip to content

Instantly share code, notes, and snippets.

@kevyworks
Forked from brentertz/emitter.js
Created April 16, 2014 10:25
Show Gist options
  • Save kevyworks/10848685 to your computer and use it in GitHub Desktop.
Save kevyworks/10848685 to your computer and use it in GitHub Desktop.
var util = require('util'),
EventEmitter = require('events').EventEmitter;
var Server = function() {
var self = this;
this.on('custom_event', function() {
self.logSomething('custom_event');
});
this.logSomething('init');
};
util.inherits(Server, EventEmitter);
Server.prototype.doSomething = function() {
this.emit('custom_event');
};
Server.prototype.logSomething = function(something) {
console.log(something);
}
var s = new Server();
s.doSomething();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment