Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/realizehit/subscription
realizehit subscription lib
https://github.com/realizehit/subscription
Last synced: 16 days ago
JSON representation
realizehit subscription lib
- Host: GitHub
- URL: https://github.com/realizehit/subscription
- Owner: realizehit
- License: gpl-3.0
- Created: 2015-05-20T21:49:38.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-03-08T14:45:20.000Z (almost 9 years ago)
- Last Synced: 2024-11-07T16:07:07.049Z (about 2 months ago)
- Language: JavaScript
- Size: 42 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# realizehit-subscription [![Build Status](https://travis-ci.org/realizehit/subscription.svg?branch=master)](https://travis-ci.org/realizehit/subscription)
Subscription pattern handling for realizehit
Probably you might want to use [realizehit/realizehit](https://github.com/realizehit/realizehit) instead.
## Installation
```js
npm install --save realizehit-subscription
```## Usage
Subscription is used as a lib by other *realizehit* modules.
This lib is intended to generate and drive redis-valid patterns.
```js
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 );
```## FAQ
##### Why is this module separated from the core?
Because it is to be used on both repos.
##### Why don't you never use `subscription` object?
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.##### Pattern? Why Pattern?
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.
```js
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 );```