Skip to content

download13/asemitter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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');

About

A tiny event emitter library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published