CancelToken

A cancellation token loosely based on the proposal.

Hierarchy

  • EventEmitter<{ }>

    CancelToken

Constructors

constructor

+ new CancelToken(executor: (cancel: () => void) => void): CancelToken

Create a new cancellation token.

The executor callback is called immediately by this constructor. It gets passed the cancel callback, which should be called on a cancellation request.

example this token is cancelled after a second passes:

const token = new CancelToken((cancel) => setTimeout(cancel, 1000));

Parameters:

NameType
executor(cancel: () => void) => void

Returns: CancelToken

Overrides: EventEmitter<{ /* @internal / _cancel: []; }>.constructor

Accessors

isCanceled

• get isCanceled(): boolean

Returns: boolean

Methods

cancelAfter

StaticcancelAfter(ms: number): CancelToken

Create a token that is automatically cancelled after ms milliseconds.

Parameters:

NameType
msnumber

Returns: CancelToken

Found a mistake? Email us, and we'll send you a free t-shirt!

Enroll in beta

Request invite to our private Beta program for developers to join the waitlist. No spam, we promise.