super-event-emitter
Lightweight and simple interpretation of popular event management
Last updated 7 years ago by piecioshka .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install super-event-emitter 
SYNC missed versions from official npm registry.

super-event-emitter

node version npm version downloads count travis-ci coveralls snyk

:hammer: Lightweight and simple interpretation of popular event management / aggregation

Motivation

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

Installation

npm install super-event-emitter

Usage — CommonJS

const EventEmitter = require('super-event-emitter');
// or
const { EventEmitter } = require('super-event-emitter');

Usage — ECMAScript Modules (ex. in TypeScript world)

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 });
    }
}

Demo #1 — Typical object literal

const bar = {};

EventEmitter.mixin(bar);

bar.on('test', function () {
    console.log('triggered!');
}, this);

bar.emit('test');

Demo #2 — Class API from ECMAScript 2015

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');

Documentation

Unit tests

npm test

Code coverage

npm run coverage

License

The MIT License @ 2016

Current Tags

  • 4.1.12                                ...           latest (7 years ago)

23 Versions

  • 4.1.12                                ...           7 years ago
  • 4.1.11                                ...           7 years ago
  • 4.1.10                                ...           7 years ago
  • 4.1.9                                ...           7 years ago
  • 4.1.8                                ...           7 years ago
  • 4.1.7                                ...           7 years ago
  • 4.1.6                                ...           8 years ago
  • 4.1.5                                ...           8 years ago
  • 4.1.4                                ...           10 years ago
  • 4.1.3                                ...           10 years ago
  • 4.1.2                                ...           10 years ago
  • 4.1.1                                ...           10 years ago
  • 4.1.0                                ...           10 years ago
  • 4.0.0                                ...           10 years ago
  • 3.0.8                                ...           10 years ago
  • 3.0.7                                ...           10 years ago
  • 3.0.6                                ...           10 years ago
  • 3.0.5                                ...           10 years ago
  • 3.0.4                                ...           10 years ago
  • 3.0.3                                ...           10 years ago
  • 3.0.2                                ...           10 years ago
  • 3.0.1                                ...           10 years ago
  • 3.0.0                                ...           10 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 4
Dependencies (0)
None
Dev Dependencies (8)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |