Skip to content

🔨 Lightweight and simple interpretation of popular event management / aggregation

License

Notifications You must be signed in to change notification settings

piecioshka/super-event-emitter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

super-event-emitter

node version npm version downloads count size license github-ci

🔨 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