Simple message queue and distribution
Version 0.0.3
Mainland in a message bus that lets you reliably distribute messages between different parts of your app.
All methods take a callback that is called with err and result. The
signatures below use done
to identify the callback.
Delete everything
### quit(done)Quit everything
### purge(topic, done)Delete all unprocessed messages from a topic
### send(topic, data, done)api.send('my-topic', {foo: 'bar'}, next);
Add a message data
to the topic queue
var done = function(err, data){};
Takes one (if any) message off the topic queue
### listen(topic, handler)var handler = function(err, data){};
Watches the end of the topic queue and calls handler
with the next
available message.
Multiple listeners on the same topic will compete for messages.
If you want to distribute the same message to multiple handlers, use
#router
Fans out one topic to multiple topics
Router is like
{'source-topic':['target-1','target-2'], ...}
- 28/01/2014 0.0.1 Initial release
- 03/11/2014 0.0.3 Redux
Copyright (c) 2014 Simon Swain Licensed under the MIT license.