公司小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cjbbdd 6cf93df28e 新增界面等。。。 3 years ago
..
doc 新增界面等。。。 3 years ago
lib 新增界面等。。。 3 years ago
LICENSE 新增界面等。。。 3 years ago
README.md 新增界面等。。。 3 years ago
README_zh.md 新增界面等。。。 3 years ago
package.json 新增界面等。。。 3 years ago

README.md

onfire.js

nano version (~ 500b) for event-emitter.

Build Status npm

中文文档 | English Doc

Install

npm i --save onfire.js

Usage

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.