Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hustcc/onfire.js
:gun: onfire.js is a nano version (~500b) for event-emitter.
https://github.com/hustcc/onfire.js
emitter event-dispatcher event-emitter onfire
Last synced: about 2 months ago
JSON representation
:gun: onfire.js is a nano version (~500b) for event-emitter.
- Host: GitHub
- URL: https://github.com/hustcc/onfire.js
- Owner: hustcc
- License: mit
- Created: 2016-07-15T07:10:34.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-04-22T01:33:25.000Z (over 5 years ago)
- Last Synced: 2024-04-25T13:40:46.847Z (5 months ago)
- Topics: emitter, event-dispatcher, event-emitter, onfire
- Language: TypeScript
- Homepage: https://github.com/hustcc/onfire.js
- Size: 38.1 KB
- Stars: 498
- Watchers: 31
- Forks: 108
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-tiny-js - onfire.js - Also has `.once` method, <img align="top" height="24" src="./img/onfirejs.svg"> (Event Emitters)
README
# onfire.js
> nano version (~ 500b) for event-emitter.
[![Build Status](https://travis-ci.org/hustcc/onfire.js.svg?branch=master)](https://travis-ci.org/hustcc/onfire.js)
[![npm](https://img.shields.io/npm/v/onfire.js.svg)](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');
```## API
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.## Used
- Events subscribe and dispatcher.
- `Cross-component communication` for React / Vue / Angular.
- System event mechanism.## License
MIT@[hustcc](https://github.com/hustcc).