Skip to content

Instantly share code, notes, and snippets.

@ben-bradley
Created September 26, 2013 15:54
Show Gist options
  • Save ben-bradley/6716177 to your computer and use it in GitHub Desktop.
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
/*
* 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