JSPM

  • Created
  • Published
  • Downloads 1727
  • Score
    100M100P100Q116339F
  • License MIT

Event Emitter wrapper for redis

Package Exports

  • remitter

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (remitter) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Remitter

Build Status

Description

Redis is awesome. But have you seen how one accomplishes pub/sub with the (otherwise incredibly awesome) redis module? Good ol' fashion event emitting/listening but using redis instead of node's native event emitter.

Redis

You need a redis instance. Configure it in your environment (replace host and port with your instance info)

$ export REDIS_URL=redis://127.0.0.1:6379/

Install

$ npm install remitter --save

Usage

  const Remitter = require('remitter');
  const thing = Remitter(process.env.REDIS_URL);

  thing
    .connect()
    .then(() => {
      thing.on('foo', (foo) => {
        console.log('foo'); // { beep: 'boop' }
      });
    });

    // .... elsewhere in your app - maybe even another process!
    const thing2 = Remitter(process.env.REDIS_URL);
    thing2
      .connect()
      .then(() => {
        thing2.emit('foo', { beep: 'boop' });
      });
  

  // ...some time later
  thing.destroy();
  thing1.destroy();

Test

$ echo "REDIS_URL=redis://127.0.0.1:6379/" >> test/test.env
$ npm test