collect-methods

1.2.0 • Public • Published

collect-methods Build Status devDependency Status

Collect a series of methods then run them. Kind of like an event emitter where everything is once.

Installation

npm install collect-methods

Usage

var Collector = require('collect-methods');
 
var stop = Collector();
 
module.exports = {
  start: start,
  stop: stop,
  restart: restart
};
 
function start () {
  // init state object and stuff...
  stop(Delegator());
  stop(Router.watch(app.router));
  stop(SomeOtherInit);
 
  return stop;
}
 
function restart () {
  stop();
  start();
}

API

CollectMethods() -> collector

Create a new method collector instance.

collector(method) -> removeListener

Add a new method to the collector. Returns a removeListener function. When executed, removeListener returns an array of the methods removed from the queue.

method

Required
Type: function

The handler to execute when the collector is run

collector()

Executes all of the methods in the queue and clears it. Subsequent calls will do nothing until new handlers are added.

Contributing

npm run test

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i collect-methods

Weekly Downloads

3

Version

1.2.0

License

MIT

Last publish

Collaborators

  • chrisinajar