npm

Need private packages and team management tools?Check out npm Orgs. »

reacher

1.0.0 • Public • Published

Reacher

Reacher is light-weight request-value bus.

Dependencies

None.

Installation

  • Clone this repository; or
  • Download the dist/reacher.js; or
  • bower install reacher; or
  • npm install reacher

Sample usage

var reacherBus = new Reacher();
 
reacherBus.handle('foo', function(arg){
    return arg;
});
 
var val = reacherBus.request('foo', 41); // 41

or construct in node

var reacherBus = require('reacher').Reacher();
// ...

API

{void} handle(command, callable)

Register a command handler for given command name. Only 1 command handler is permitted at any given time.

throws ReacherError when command handler already set. throws ReacherError when command handler is not a function.

{*} request(command, ...args)

Request a command value by name and with optional arguments passed on to handler.

throws ReacherError when handler does not exist.

{function} removeHandler(command)

Remove a command handler from registry and return the handler function.

throws ReacherError when command handler does not exist.

{boolean} hasHandler(command)

Determine whether the handler is set for given command name.

License

Licensed under terms and conditions of Apache 2.0 license.

install

npm i reacher

Downloadsweekly downloads

4

version

1.0.0

license

Apache-2.0

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability