Created
September 26, 2013 15:54
-
-
Save ben-bradley/6716177 to your computer and use it in GitHub Desktop.
A simple way to extend the EventEmitter to classes with the class.extend module in NodeJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* A simple way to extend the EventEmitter to classes with the class.extend module in NodeJS | |
*/ | |
var Class = require('class.extend'), | |
events = require('events'); | |
var Events = Class.extend({ | |
init: function() { events.EventEmitter.call(this); } | |
}); | |
Events.super_ = events.EventEmitter; | |
Events.prototype = Object.create(events.EventEmitter.prototype, { | |
constructor: { value: Events, enumerable: false } | |
}); | |
module.exports = Events; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment