onfire.js
Version:
onfire.js is a mini (~500 b) version for event-emitter.
59 lines (28 loc) • 1.11 kB
Markdown
nano version (~ 500b) for event-emitter.
[](https://travis-ci.org/hustcc/onfire.js)
[](https://www.npmjs.com/package/onfire.js)
[中文文档](./README_zh.md) | [English Doc](./README.md)
## Install
> npm i --save onfire.js
## Usage
```js
import EE from 'onfire.js';
const ee = new EE();
ee.on('mouseover', () => {});
ee.once('click', () => {});
ee.fire('click', 1, 'hello', true);
ee.off('click');
```
Simple and similar with `event-emitter`.
- `on(eventName: string, callback: Function)`: listen an event.
- `once(eventName: string, callback: Function)`: listen a event only once.
- `fire(eventName: string, ...parameters: any[])`: emit / trigger an event with parameters.
- `off(eventName?: string, callback?: Function)`: unsubscribe an event.
- Events subscribe and dispatcher.
- `Cross-component communication` for React / Vue / Angular.
- System event mechanism.
MIT@[hustcc](https://github.com/hustcc).
>