@mooyu/fire
a tool via publish the subscription mode
Last updated 2 years ago by huangteng .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @mooyu/fire 
SYNC missed versions from official npm registry.

@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()

Current Tags

  • 1.0.1                                ...           latest (2 years ago)

2 Versions

  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (33)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |