Package Exports
- cancellationtoken
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cancellationtoken) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Cancellation Token
Cancellation tokens are composable entities that allow cancelling asynchronous operations.
The implementation roughly follows these TC39 proposals:
The implementation is written in TypeScript and therefore comes with typings already bundled.
Installation
Install the library via your favourite package manager.
npm install cancellationtoken
or
yarn add cancellationtoken
Usage
You can create a new cancellation token along with a function to cancel it via create
. Functions can consume tokens by accessing the ìsCancelled
property.
import CancellationToken from 'cancellationtoken'
const { cancel, token } = CancellationToken.create()
console.log(token.isCancelled) // prints false
cancel()
console.log(token.isCancelled) // prints true
Documentation
Coming soon! Meanwhile you can use the TypeScript definitions and examples.
Examples
For usage examples have a look at the examples/
directory.
cd examples/
npm install
npm run example 01-tutorial
npm run example <name>
or
cd examples/
yarn
yarn run example 01-tutorial
yarn run example <name>