pattern matched composition for browser apps
varo is a pattern matched logic library designed for the browser. Varo is designed to compliment Seneca by providing a similar, albeit, smaller set of API's. It's ideal use case is in browser-side apps.
The focus of Varo is to provide the ability to compose logic around patterns; it does not handle transport or any other concerns.
If you're using this module, and need help, you can:
To install, simply use npm,
npm install varo
To run tests, simply use npm:
npm run test
'use strict'var Varo =// Only one handler will be called, more specific wins,// then insertion order is checked on two identical matches.Varo// Won't be called unless the pattern above was removedVaro// Listen for anything emitted via emitVaroVaro// Get a response to a message. Handy for asking for data or// making calculations.Varo// You don't have to use a callback, if you are running an handler that// doesn't respond then it is ok to leave it out.Varo
.handle(msg, handler(err, reply)) : this
Adds a handler for the msg provided. The handler is called when .act() is used. Note that only one handler will be called.
.observe(msg, observer(msg)) : this
Adds an observer that listens for any message matching the msg param. The observer is called when .emit() is used. Multiple observers can handle a single message; there is no callback
.act(msg [, reply]) : this
Sends the provided message to any interested single handler. Calls to act can be fire and forget or request response as necessary.
.emit(msg) : this
Sends the provided message to any interested observers. Calls to emit have no callback and are
considered fire and forget. This makes
.emit() / .observere() a great pattern matched replacement
for event emitters.
.plugin(plugin(Varo)) : this
Calls the provided function with the current instance of varo. Useful to group functionality together in modular format.
.removeHandler(handler) : this
Removes a named handler. Does not work for anonymous functions.
.removeObserver(observer) : this
Removes a named observer. Does not work for anonymous functions.
The Senecajs org encourages open participation. If you feel you can help in any way, be it with documentation, examples, extra testing, or new features please get in touch.
Copyright (c) 2015, Dean McDonnell and other contributors.
Licensed under MIT.