RedisEmitter
Install and test
npm install --save redisemitternpm test
Setup
const RedisEmitter = const options = host: 'localhost' port: 6379 index: 'type' 'action' 'name' 'id'const events = options
options
- host the host redis should connect to.
- default:
'127.0.0.1'
- default:
- port the port redis should connect to.
- default:
6379
- default:
- query the default query all event strings will be generated from.
- default:
['type', 'action', 'name', 'id']
- default:
Emitting events
emit only takes one argument and the event pattern will be built from the message. In this case event:emit:*:*
events
Subscribing to events
Unlike EventEmitter you subscribe to objects instead of strings (a string will be generated from your query). In this case event:*:*:*
events
subscriptions
- on(query, callback) subscribe to all events matching the query
- once(query, callback) subscribe to the first event matching the query
- any(callback) subscribe to any event
Unsubscribing to events
All subscriptions return a disposer that can be called to dispose the event listener.
const dispose = events