Name: cancel-token
Owner: PolymerLabs
Description: Implementation of https://github.com/littledan/proposal-cancelable-promises
Created: 2016-12-15 00:01:57.0
Updated: 2018-02-21 23:02:02.0
Pushed: 2018-02-23 19:45:09.0
Size: 27
Language: TypeScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
rt {CancelToken} from 'cancel-token';
t source = CancelToken.source();
t result = someCancellableApi(source.token);
tSource.on('dont-care-about-result-anymore', () {
urce.cancel();
his may throw a Cancel if we called source.cancel().
t value = await result;
lsewhere, maybe in another library
c function someCancellableApi(cancelToken) {
ait doSomeWork(cancelToken);
I'm outside of a critical section here, so it's ok if I were to throw.
ncelToken.throwIfRequested();
turn doSomeMoreWork(cancelToken);
To test:
npm test
To watch source files and rerun tests when they change:
npm test:watch
This is based on a proposed cancellable promises spec which has since been withdrawn / gone dormant.
See https://github.com/littledan/proposal-cancelable-promises for more details.