Skip to content

A Simple PubSub Framework, working locally, with regexp feature.

Notifications You must be signed in to change notification settings

stouf/node-simple_pubsub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SimplePubSub

This module has been developed with the wish to provide a simple local pubsub system, providing a simple and easy-to-use API.

How to install

Install it either by cloning this repo, or via npm ;-)

How to use

var PubSub = require('simplepubsub');
var pubsub = new PubSub();

var onPublish = function (channel, args) {
  console.log('Message received on ' + channel + ': ' + JSON.stringify(args));

  // I do not want to receive those messages anymore!
  pubsub.unsubscribe([channel]);
};

var regexp = new RegExp('channel.*', 'g');

pubsub.subscribe(['channel1', 'channel2', 'channel3'], onPublish);
pubsub.regexpSubscribe([regexp], onPublish);

// Stop listening to the regexp after 2 seconds
setTimeout(function () {
  pubsub.regexpUnsubscribe([regexp]);
}, 2000);

Check out the JSDoc (JSDox) in the doc directory.

About

A Simple PubSub Framework, working locally, with regexp feature.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published