@mooyu/fire
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

@mooyu/fire

styled with prettier Greenkeeper badge Travis Coverage Status

a tool via publish the subscription mode

Usage

npm install @mooyu/fire -D
yarn add @mooyu/fire --dev

// then
import fire from '@mooyu/fire'

API

  1. fire.on
// Subscribers subscribe to an event, which can be emit by priority
fire.on(evtName: string, cb: Function, priority: number = Infinity)
  1. fire.once
// only emit once
fire.once(evtName: string, cb: Function, priority: number = Infinity)
  1. fire.emit
// A publishing method that triggers a subscribed event.
//The argument can be a string or an array of strings, or it can be passed without arguments(emit all). data is a message that is pushed to the subscriber.
// The function accepts an array as the return value as a message that the subscriber feeds back to the publisher. Two-way communication
fire.emit(evtName?: string | Array<string>, data?: any) : Array
  1. fire.off
// cacel the subscribtion
fire.off(evtName: string| Array<string>, fn?: Function)
  1. fire.destory
// clear all
fire.destory()
  1. fire.curr
// return all the data in cache object
fire.curr()

Package Sidebar

Install

npm i @mooyu/fire

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

30.9 kB

Total Files

16

Last publish

Collaborators

  • huangteng