Skip to content
Elliot Hesp edited this page Jul 28, 2016 · 8 revisions

RediBox core PUBSUB is more than just the standard ioredis/node_redis clients single 'message' event handler. It's setup to allow subscribing just like you would with a node event emitter. Internally though, RediBox has a on 'message' handler that routes pubsub messages to an event emitter which you're listening to when you subscribe, this gives you better control over channel flow.

A number of methods exist to handle PUBSUB with Redis which can be found at the API Specification.

RediBox PUBSUB is an internal Hook and is accessed via the pubsub namespace on RediBox.

Usage

RediBox
  .pubsub
  .subscribe(
    'fooChannel', 
     message => {
       console.log('new message!', message);
     },
     error => {
       if (error) console.error('Error while subscribing', error);
       else console.log('Subscribed to fooChannel');
     },
  );
Clone this wiki locally