cancelable-group

0.1.0 • Public • Published

npm

cancelable-group

Build Status Dependency Status

Create groups of callbacks that can be canceled in one go.

Think FGRibreau/cancelable for groups or substack/node-toss without timeouts and the extra stuff. This module is focused on one thing.

Example

var cancelableGroup = require('cancelable-group');
 
var group = cancelableGroup();
 
asyncFunction1(arg1, arg2, group(function (err, data) {
  // Won't fire after cancel() call.
}));
 
asyncFunction2(arg1, arg2, group(function (err, data) {
  // Won't fire after cancel() call.
}));
 
someOtherFunction(function () {
  // ...
  group.cancel();
}));

API

group = cancelableGroup()

Creates new cancelable group.

group(func)

Returns a wrapper function that is equivalent to func unless the group is canceled. Then it becomes a no-op.

group()

group.cancel()

Cancels the group.

Install

npm install cancelable-group

License

MIT

Package Sidebar

Install

npm i cancelable-group

Weekly Downloads

2

Version

0.1.0

License

MIT

Last publish

Collaborators

  • eush77