super-event-emitter
v5.0.2
Published
🔨 Lightweight and simple interpretation of popular event management
Downloads
471
Readme
super-event-emitter
🔨 Lightweight and simple interpretation of popular event management / aggregation
Motivation
I was created a blog post (in polish) about motivation why I created this tool: https://piecioshka.pl/blog/2016/01/29/narzedzia-swiata-super-event-emitter.html
(I'm sorry, but I don't have time to translate this article into English)
Installation
npm install super-event-emitter
Usage — CommonJS
const { SuperEventEmitter } = require('super-event-emitter');
const bar = {};
SuperEventEmitter.mixin(bar);
bar.on('test', function () {
console.log('triggered!');
});
bar.emit('test');
Usage — ECMAScript Modules *.mjs
or TypeScript *.ts
import { SuperEventEmitter } from "super-event-emitter";
class Person extends SuperEventEmitter {
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');
Documentation
API Documentation is available in separated document.
License
The MIT License @ 2016-2024