js-pub-n-sub
TypeScript icon, indicating that this package has built-in type declarations

1.1.3 • Public • Published

js-pub-n-sub

pipeline status coverage report

Has

  • ...No external dependencies.
  • ...Tests with tape.
  • ...Decoupled publishing, i.e. non-blocking. Inspired by pubsub-js
  • ...Small source, but not quite as tiny as tiny pubsub

Install

npm i js-pub-n-sub

Compatibility

Uses ECMA features. Minimum node.js version: 6

Usage

Initialise a new channel

const pubSubChannel = require('js-pub-n-sub')();

Subscribe and publish

const subscriberFn = ({name}) => console.log(`Hello ${data}`);
const topic = 'greeting';

pubSubChannel.subscribe(topic, subscriberFn);
pubSubChannel.publish(topic, {name: 'World!'});
pubSubChannel.publish(topic, {name: 'Mars!'});

Pass the channel to consumers

require('ui-factory')(pubSubChannel);
require('model-factory')(pubSubChannel);

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.1.3
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.1.3
    0
  • 1.1.2
    0
  • 1.1.1
    0

Package Sidebar

Install

npm i js-pub-n-sub

Weekly Downloads

0

Version

1.1.3

License

MIT

Unpacked Size

19.1 kB

Total Files

15

Last publish

Collaborators

  • fruityfreedom