Subscription pattern handling for realizehit
Probably you might want to use realizehit/realizehit instead.
npm install --save realizehit-subscription
Subscription is used as a lib by other realizehit modules.
This lib is intended to generate and drive redis-valid patterns.
var redis = require( 'redis' )( /* ... */ );
var Subscription = require( 'realizehit-subscription' );
var subscription = new Subscription();
// Add a channel filter
subscription.pattern.add( 'channel', 'CNN' );
// Add a show filter
subscription.pattern.add( 'show', 'tvnews' );
// gather the channel needed by redis
redis.psubscribe( subscription.pattern );
Because it is to be used on both repos.
In fact we use it to store pattern
, but methods on subscription
should be
handled on realizehit
(or your app) to contain specific approaches that
interact directly with pattern handling.
We need it as so because server
and client
has different methodologies for
actions such as subscribe
, unsubscribe
and so on.
We use Pattern Subscription (PSUBSCRIBE) on redis instead of SUBSCRIBE. It allows us to create a wide subscription methodology!
Example: Subscribe to entire CNN Shows.
var Subscription = require( 'realizehit-subscription' );
var subscription = new Subscription();
// Add a channel filter
subscription.pattern.add( 'channel', 'CNN' );
// Add a show filter
subscription.pattern.add( 'show', Subscription.Pattern.Chunk.ALL );