super-event-emitter
TypeScript icon, indicating that this package has built-in type declarations

5.0.2 • Public • Published

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

Package Sidebar

Install

npm i super-event-emitter

Weekly Downloads

173

Version

5.0.2

License

MIT

Unpacked Size

24.4 kB

Total Files

8

Last publish

Collaborators

  • piecioshka
  • mateuszkocz