Skip to content
a simple Readable stream to consume JSON published over redis pub/sub https://github.com/jcrugzz/subscribe-stream
JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
example
test
.gitignore
.travis.yml
LICENSE
README.md
index.js
package.json

README.md

subscribe-stream

build status

NPM

A simple Readable object stream that consumes the data published to a specific redis pub/sub channel using node_redis.

note: We assume that it is a stringified json object coming through the pub/sub channel that is again parsed into an object because they are much nicer to deal with. This can be seen in the example below.

This makes it especially useful for consuming godot data sent using the redis reactor.

Example

var redis = require('redis'),
    subscribeStream = require('../');

var stream = subscribeStream({ subscription: 'hithere' });

var client = redis.createClient();

var testObj = {
  test: 'value',
  other: 'otherValue'
};

stream.on('readable', function () {
  var obj = stream.read();
  console.log('obj', obj);
});

client.publish('hithere', JSON.stringify(testObj));

Which outputs:

obj { test: 'value', other: 'otherValue' }

Test

npm test

License

MIT

Something went wrong with that request. Please try again.