cancellation
A method for making async operations cancellable
Installation
Component:
$ component install ForbesLindesay/cancellation
NPM:
$ npm install cancellation
API
tokenSource()
Returns a new CancellationTokenSource:
var tokenSource = ;var source = ;;;
tokenSource.empty
Returns an 'empty' CancellationToken (one that will never be cancelled).
var tokenSource = ; { cancellationToken = cancellationToken || tokenSourceempty; //Continue with function knowing there is a cancellation token}
CancellationToken.isCancelled()
Returns true if the token has been cancelled:
//In ES6 { return }
CancellationToken.throwIfCancelled()
Throws the rejection reason if the token has been cancelled:
//In ES6 { return }
CancellationToken.onCancelled(cb)
Calls cb when the cancellation token is cancelled (this is probably currently the most useful of these methods).
{ var def = ; var req = ; cancellationToken ; return defpromise;}
License
MIT