cancelify
A javascript library for making async operations cancelify
Installation
$ npm install cancelify --save
API
cancelify
cancelify()
Returns a new cancelify:
var cancelify = ; var cancelable = ;; ;
cancelify.future()
Returns an 'empty' future (one that will never be canceled).
{ future = future || cancelify; // Continue with function knowing there is a cancelable}
cancelable
cancelable.cancel()
Cancels the current async operations.
var cancelify = ;var cancelable = ; ; cancelable;
cancelable.canceled([callback])
If no arguments provide, returns true if the cancelable has been canceled:
//In ES6 { return }
If canceled with a callback, calls callback when the cancelable is canceled (this is probably currently the most useful of these methods).
{ var req = ; future;}
cancelable.throwIfCanceled()
Throws the reason if the cancelable has been canceled:
//In ES6 { return }
cancelable.future()
Returns future functions delegates cancelable:
cancel
canceled
throwIfCanceled
License
Copyright (c) 2014 Tao Yuan. Licensed under the MIT license.