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:
Name | Type |
---|---|
executor | (cancel : () => void) => void |
Returns: CancelToken
Overrides: EventEmitter<{ /* @internal / _cancel: []; }>.constructor
Accessors
isCanceled
• get isCanceled(): boolean
Returns: boolean
Methods
cancelAfter
▸ Static
cancelAfter(ms
: number): CancelToken
Create a token that is automatically cancelled after ms
milliseconds.
Parameters:
Name | Type |
---|---|
ms | number |
Returns: CancelToken