1.1.3 • Published 6 years ago

js-pub-n-sub v1.1.3

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
6 years ago

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);
1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago