# utiltool-pubsub

> 实现发布订阅模式

Latest version **1.1.0** (published 2020-08-20) · ISC license · 0 weekly downloads

## Install

```sh
npm install utiltool-pubsub
pnpm add utiltool-pubsub
yarn add utiltool-pubsub
bun add utiltool-pubsub
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2020-08-20 |
| First published | 2019-01-03 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 66.5 KB |
| Known vulnerabilities | 0 (+24 in 1 direct dependencies) |
| Install scripts | no |
| Author | cl |
| Maintainers | chenglie33 |
| Keywords | 发布订阅 |

## Links

- npm: https://www.npmjs.com/package/utiltool-pubsub
- npm.io page: https://npm.io/package/utiltool-pubsub

## Dependencies (3)

- [axios](https://npm.io/package/axios.md) ^0.18.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.11
- [@babel/polyfill](https://npm.io/package/@babel/polyfill.md) ^7.2.5

## Recent versions

- 1.1.0 (latest) — 2020-08-20
- 1.0.7 — 2019-01-29
- 1.0.6 — 2019-01-29
- 1.0.5 — 2019-01-29
- 1.0.4 — 2019-01-29
- 1.0.3 — 2019-01-17
- 1.0.2 — 2019-01-09
- 1.0.1 — 2019-01-07
- 1.0.0 — 2019-01-03

## README

# utilTool
集成常用的方法驱动<br/>
引入方式<br/>
``` bash
    npm i utiltool-pubsub
    import {MessageCenter,Utiltool} from 'utiltool-pubsub'
```
####目录

####订阅发布驱动
首先实例化参数 new MessageCenter（）<br/>
API<br>
``` bash
MessageCentr
    |--sub() 注册驱动方法
    |   |-name 注册的名称 
    |   |-{ fn, context } 注册的方法 上下文
    |--subOnce（） 注册驱动方法 在第一次执行以后将会被注销
    |--pub（'name',[,...args] ） 执行注册方法 同步方法 args：参数
    |--pubAsync('name',[,...args] ） 执行注册方法 同步方法 args：参数
    |--removeSub（） 删除指定的驱动名称
    |   |-name 注册的名称
    |--clearMessageCenter（） 注销所有的驱动
    |--getMessageName（） 获取注册的所有的驱动名称
    |--setGlobal() 设置全局变量 return 返回全局名称Symbol
    |    |-name
    |    |-value   
    |--getGlobal() 获取指定的全局变量
    |    |-name
      
```
####工具类
Utiltool静态方法<br>
API<br>
```bash
Utiltool
    |-isEmpty(data) 判断是否为空 去除空格 false为空
    |-getUrlparam(value) 获取地址栏的参数
    |-dateFormat(fmt, date) 时间格式化
    |-accAdd (arg1, arg2) 加
    |-accSubtr (arg1, arg2) 减
    |-accMul (arg1, arg2) 乘
    |-accDivCoupon (arg1, arg2)  除
```

---
_Source: https://npm.io/package/utiltool-pubsub · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
