jiken
v0.2.3
Published
Browser EventEmitter
Downloads
5
Readme
事件(jiken)
Simple EventEmitter for Browser.
Documentation
Overview
This package's goal is to emulate node.js EventEmitter.
But adds some cool flavour on top of it.
Async mode
Contrary to node.js EventEmitter, Jiken gives you possibility to run listeners asynchronously.
Under hood it uses setTimeout
Install
npm
npm install --save jiken
Browser
Alternatevly you can grab built copy from repository:
<script src="https://github.com/DoumanAsh/jiken/releases/download/0.2.2/jiken.min.js">
Usage
Extend Class
const Jiken = require('jiken').Jiken;
class MySuperEmitter extends Jiken {
constructor() {
super()
this.on('some-event', () => console.log('trigger some-event'));
}
}
const emitter = new MySuperEmitter();
emitter.emit('some-event');
Directly Create Instance
const Jiken = require('jiken').Jiken;
const test = new Jiken();
test.on('lolka', () => console.log('lol'));
test.emit('lolka');