0.2.5 • Published 5 years ago

pubsubjs-m4r v0.2.5

Weekly downloads
22
License
MIT
Repository
github
Last release
5 years ago

PubSubJS

Build Status

Simple pubsub solution for node and web

Use

  • CDN
    • Production
      <script src="https://unpkg.com/pubsubjs-m4r/dist/umd/pubsubjs.prod.js"></script>
    • Development
      <script src="https://unpkg.com/pubsubjs-m4r/dist/umd/pubsubjs.dev.js"></script>
  • npm

    npm i -S pubsubjs-m4r
  • yarn

    yarn add pubsubjs-m4r

How to use

import PubSubJS from 'pubsubjs-m4r'
// Or
// const PubSubJS = require("pubsubjs-m4r").default

// Subscribe to topic "abc"
const sub = PubSubJS.subscribe('abc', data => {
    // Your code
    console.log(data)
})

// Publish to topic "acb"
PubSubJS.publish('abc', 'Hello')

// unsub!!
sub()

API

  • PubSubJS

    • Subscribe - subscribe to notifications on a given topic
    subscribe: (topic: string, cb: Action<any>) => UnsubAction
    • Publish - publishes to a given topic
    publish: (topic: string, data: any, sync?: boolean) => void;
    • ClearAllSubscriptions - removes all subscriptions
    clearAllSubscriptions: () => void;
- ClearAllByTopic  - removes all subscriptios on a topic
```typescript
clearAllByTopic: (topic: string) => void;

```

- GetTopics -  get the registered topics
```typescript
getTopics: () => string[];
```
0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.12

5 years ago

0.1.11

5 years ago

0.1.10

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago