super-event-emitter
Version:
šØ Lightweight and simple interpretation of popular event management
68 lines (44 loc) ⢠1.97 kB
Markdown
[](https://www.npmjs.com/package/super-event-emitter)
[](https://badge.fury.io/js/super-event-emitter)
[](https://www.npmjs.com/package/super-event-emitter)
[](https://packagephobia.com/result?p=super-event-emitter)
[](https://piecioshka.mit-license.org)
[](https://github.com/piecioshka/super-event-emitter/actions/workflows/testing.yml)
šØ Lightweight and simple interpretation of popular event management / aggregation
I was created a blog post (in polish) about motivation why I created this tool:<br/>
<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)_
## Usage ā CommonJS
Installation:
```bash
npm install super-event-emitter
```
```javascript
const { SuperEventEmitter } = require('super-event-emitter');
const bar = {};
SuperEventEmitter.mixin(bar);
bar.on('test', function () {
console.log('triggered!');
});
bar.emit('test');
```
```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');
```
API Documentation is available in separated [document](./docs/api.md).
[](https://piecioshka.mit-license.org) @ 2016