subscribe-stream
v0.2.0 redis pub sub subscribe stream
subscribe-stream
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.
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));
Test
npm test
License
MIT
npm i subscribe-stream
Source Code
github.com/jcrugzz/subscribe...Metadata
- MIT
- 0.10.x || 0.8.x
- Jarrett Cruger
- released 8/6/2013