Skip to content

Latest commit

 

History

History
29 lines (22 loc) · 1.06 KB

README.md

File metadata and controls

29 lines (22 loc) · 1.06 KB

npm Travis (.org)

cancellationTokenSource.js

CancellationTokenSource implementation for JavaScript based on the C# implementation of the same name

Installation

npm install cancellation-token-source

Usage

import {CancellationTokenSource} from "cancellation-token-source";

async function myAsyncFunc(cancellationToken: CancellationToken): Promise<void> {
  const result = await someOtherThing();
  cancellationToken.throwIfCancellationRequested();

  // Perform things we don't want to happen when canceled
}

const cts = new CancellationTokenSource();
myAsyncFunc(cts.token);

API

See the API docs