A event emitter for browser


Simple Event Emitter for browser. Using object as the agent of events. You can use this both node and browsers.

Install with npm:

npm install browser-emitter
var Emitter = require('browser-emitter');
var emitter = new Emitter();
emitter.on('hoge', function(){ console.log(arguments) });
emitter.emit('hoge', 'a', 'b', 'c'); // => 'a', 'b', 'c'
<script type="text/javascript" src="Emitter.js"></script>
<script type="text/javascript">
    var emitter = new Emitter();
    emitter.on('hoge', function(){ console.log(arguments) });
    emitter.emit('hoge', 'a', 'b', 'c'); // => ['a', 'b', 'c']
// for Singleton
var MyClass = function(){
  this.__proto__.__proto__ = new Emitter();

// for Factory
var MyClass = function(){;
for(var i in Emitter.prototype)
  MyClass.prototype[i] = Emitter.prototype[i];