onfire.js
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

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.

Dependencies (0)

    Dev Dependencies (9)

    Package Sidebar

    Install

    npm i onfire.js

    Weekly Downloads

    187

    Version

    2.0.1

    License

    MIT

    Unpacked Size

    9.92 kB

    Total Files

    7

    Last publish

    Collaborators

    • atool