# pm2-pubsub

> Based on WS (UWS compatible)

Latest version **2.0.1** (published 2017-03-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install pm2-pubsub
pnpm add pm2-pubsub
yarn add pm2-pubsub
bun add pm2-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 | 2.0.1 |
| Published | 2017-03-26 |
| First published | 2017-02-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.0 |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | unitech |
| Maintainers | tknew |

## Links

- npm: https://www.npmjs.com/package/pm2-pubsub
- Repository: https://github.com/Unitech/pm2-bus
- Homepage: https://github.com/Unitech/pm2-bus#readme
- Issues: https://github.com/Unitech/pm2-bus/issues
- npm.io page: https://npm.io/package/pm2-pubsub

## Dependencies (3)

- [ws](https://npm.io/package/ws.md) *
- [pmx](https://npm.io/package/pmx.md) *
- [debug](https://npm.io/package/debug.md) ^2.6.0

## Recent versions

- 2.0.1 (latest) — 2017-03-26
- 2.0.0 — 2017-03-26
- 1.4.0 — 2017-02-17
- 1.3.0 — 2017-02-17
- 1.2.0 — 2017-02-17

## README

# pm2-pubsub

Based on WS (UWS compatible)

## Usage

Server:

```js
require('pm2-pubsub')({ server : true })
```

Client:

### PUB/SUB

```js
var bus = require('pm2-pubsub')('app-name');

bus.subscribe('channel1', (message) => {
  console.log('message:', message)
})

bus.publish('channel1', { some : 'data' });
```

### RPC

Service #1:

```js
var bus = require('pm2-pubsub')('app-name');

bus.expose('myfunction', function(data, done) {
  // some processing
  return done({ success : true, my : 'data' });
});
```

Consumer #1:

```js
var bus = require('pm2-pubsub')('app-name');

bus.call('testfunction', { some : 'data'}, function(data) {
   // data = result
});
```

## License

MIT

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