0.0.4 • Published 10 years ago

emission v0.0.4

Weekly downloads
13
License
-
Repository
github
Last release
10 years ago

Emission

Version: 0.0.2

Build Status

Redis PubSub helper

Installing

npm install emission

Usage

Config

// use default Redis on localhost
var emission = require('emission')();
// use another Redis and specify a custom key prefix
var opts = {
  prefix: 'my-prefix',
  redis = {
    host: 'myredis.host',
    port: 6379
   }
};
var emission = require('emission')(opts);

Listener

// create a subscriber with a handler and listen for messages matching
// a topic (you can use * wildcards in your topic)

var handler = function(pattern, data){
  console.log(pattern, data);
};

var subscriber = api.listener(
  'my-topic',
  handler,
  done // optional callback
);
// create a subscriber with a handler only. add topics later

var subscriber = api.listener(
  handler,
  done // optional callback
);
// dynamically add a topic
subscriber.sub('another-topic');

// dynamically stop listening for a topic
subscriber.unsub('another-topic');

// dynamically stop listening for a topic
subscriber.quit(done);

Emitter

// emit a message to a topic

// messages are sent and recieved as JSON. Emission takes care of
// stringification and parsing.

emission.emit('my-topic', {foo: 'bar'});

Release History

  • 25/09/2014 0.0.0 Pre-alpha
  • 27/10/2014 0.0.2 Initial release

License

Copyright (c) 2014 Simon Swain

Licensed under the MIT license.

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

11 years ago

0.0.1

11 years ago