# wd-pub-sub

> a pattern of publish-subscribe

Latest version **1.0.1** (published 2019-09-18) · ISC license · 0 weekly downloads

## Install

```sh
npm install wd-pub-sub
pnpm add wd-pub-sub
yarn add wd-pub-sub
bun add wd-pub-sub
```

## 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.0.1 |
| Published | 2019-09-18 |
| First published | 2018-10-16 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | mapbar_front |
| Maintainers | mapbar_front |
| Keywords | publish, subscribe |

## Links

- npm: https://www.npmjs.com/package/wd-pub-sub
- npm.io page: https://npm.io/package/wd-pub-sub

## Recent versions

- 1.0.1 (latest) — 2019-09-18
- 1.0.0 — 2018-10-16

## README

# wd-pub-sub

一个简单的发布订阅的模式的实现

## how to use

```js
import PubSub from 'wd-pub-sub';

// 绑定一个事件名为event的自定义事件
PubSub.subscribe('event', function (data) {
   console.log('触发');
   console.log(data);
});

// 触发事件名为event的自定义事件
PubSub.notify('event', 123);
```
## API

### subscribe(eventName, callback);
发布一个自定义的事件

### unsubscribe(eventName, callback);
接触一个自定义的事件

### subscribeOne(eventName, callback);
发布一个只触发一次的自定义事件

### notify(eventName, callback);
触发已经发布的自定义事件

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