π¨ Lightweight and simple interpretation of popular event management / aggregation
I was created a blog post (in polish) about this tool:
https://piecioshka.pl/blog/2016/01/29/narzedzia-swiata-super-event-emitter-js.html
npm install super-event-emitter
const EventEmitter = require('super-event-emitter');
// or
const { EventEmitter } = require('super-event-emitter');
import { EventEmitter } from "super-event-emitter";
// or
// import EventEmitter from "super-event-emitter";
class Cart extends EventEmitter {
addProduct(product: Product) {
this.emit('cart:addProduct', { product });
}
}
const bar = {};
EventEmitter.mixin(bar);
bar.on('test', function () {
console.log('triggered!');
}, this);
bar.emit('test');
class Person extends EventEmitter {
say(message) {
this.emit('say', message);
}
}
const p1 = new Person();
p1.on('say', function (message) {
console.log(message); // 'I love cookie'
});
p1.say('I love cookie');
npm test
npm run coverage
The MIT License @ 2016