All Projects β†’ hustcc β†’ Onfire.js

hustcc / Onfire.js

Licence: mit
πŸ”« onfire.js is a nano version (~500b) for event-emitter.

Programming Languages

typescript
32286 projects

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

[email protected]hustcc.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].