CancelToken

A cancellation token loosely based on the proposal.

Extends

  • EventEmitter<{}>

Constructors

new CancelToken()

new CancelToken(executor): 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.

Parameters

executor

(cancel) => void

Returns

Example

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

Overrides

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

Accessors

isCanceled

Get Signature

get isCanceled(): boolean

Returns

boolean

Methods

cancelAfter()

static cancelAfter(ms): CancelToken

Create a token that is automatically cancelled after ms milliseconds.

Parameters

ms

number

Returns

Found a mistake? Let us know.

Enroll in beta

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