Skip to content
This repository was archived by the owner on Aug 10, 2021. It is now read-only.

Latest commit

 

History

History

javascript

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

repubsub.js

Repubsub is a publish-subscribe library built on top of RethinkDB. This is the javascript version of the library. There is a full article describing this library in depth.

Installation

You'll need to install RethinkDB first. You can find instructions for that on this page.

To install the library, go into the source directory containing package.json and run:

$ npm install

Usage

To connect to an exchange, create a topic and publish to it:

var repubsub = require('repubsub');

var exchange = new repubsub.Exchange('exchangeName', {db: 'databaseName'});

var topic = exchange.topic('hi.there');

topic.publish("All subscribers to 'hi.there' will pick this up");

To create a queue for listening for messages, the process is similar except you'll need to create a ReQL filter function:

function topicFilter(topic){
    return topic.match('hi.*');
}
var queue = exchange.queue(topicFilter);

queue.subscribe(function(topic, message){
    console.log('Received the message:', message);
    console.log('on the topic:', topic);
});

In addition, examples of usage can be found in the demo.js file. There is also an extensive description of how the library works and how to use it here.

Bugs

Please report any bugs at our github issue tracker