cancelable-group
v0.1.0
Published
Cancelable groups of callback functions
Downloads
3
Maintainers
Readme
cancelable-group
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