PolymerLabs/cancel-token

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

Homepage:

Size: 27

Language: TypeScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

CancelToken and Cancel Library
Use
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);

Developing

To test:

npm test

To watch source files and rerun tests when they change:

npm test:watch
History

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.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.