Cancellable

commands. Cancellable

A Cancellation Token (ct) that commands can check for cancellation. Commands should regularly check for the isCancelled attribute and exit eagerly if true. Keeps a list of timeout IDs issued by setTimeout calls and cancels them all when cancel is called, setting the isCancelled attribute to true.

Constructor

new Cancellable()

Source:

Cancellable constructor.

Members

isCancelled

Source:

If the Cancellation Token is cancelled. Starts off as false.

Methods

(package) add(timeoutID, resolve)

Source:

Registers the given timeout ID and Promise resolve function.

Parameters:
Name Type Description
timeoutID

Timeout ID, the result of calling setTimeout, platform dependent.

resolve function

Resolve function for a Promise to be called if the timeout is cancelled.

cancel()

Source:

Cancels all registered timeouts. Sets isCancelled to true. Cancellation means calling clearTimeout with the stored timeout IDs and calling the related resolve functions.

(package) del(timeoutID)

Source:

Unregisters the given timeout ID, when the timeout is reached and does not need to be cancelled anymore, or if it was cancelled.

Parameters:
Name Type Description
timeoutID

Timeout ID to unregister.