asemitter

0.0.0 • Public • Published

asEmitter

Install

npm install asemitter

Examples

var asEmitter = require('asemitter');


// Make a class instance an event emitter
function SomeObject() {
	asEmitter(this); // this is now an event emitter

	this.on('someevent', function() {
		// Do some stuff
	});
}

var instance = new SomeObject();


// Make any object into an event emitter
var emitter = asEmitter({
	getState: function() {
		return 'whatever';
	}
});


// It event works without an object
var anotherEmitter = asEmitter();

anotherEmitter.emit('testevent');

Readme

Keywords

Package Sidebar

Install

npm i asemitter

Weekly Downloads

0

Version

0.0.0

License

MIT

Last publish

Collaborators

  • download