sm-event-emitter

A super small event-emitter for javascript

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
sm-event-emitter
1.0.07 years ago7 years agoMinified + gzip package size for sm-event-emitter in KB

Readme

sm-event-emitter
A super small event-emitter for javascript =).

Install

npm install --save sm-event-emitter

Usage

```js var EventEmitter = require('sm-event-emitter'); // when NAMEOFYOUREVENT is emitted, the payload function will be called. // store the eventId to remove when you do not need anymore =). var eventId = EventEmitter.on('NAMEOFMYEVENT', function(payload) {
console.log(payload);
}); // removing an event subscription EventEmitter.remove(eventId); // emitting an event EventEmitter.emit('NAMEOFMYEVENT', { someProp: 123456 }); // clear all listeners EventEmitter.clear(); // get active listeners EventEmitter.getListeners(); ```