CurrentAction
- class Communicator.Util.CurrentAction()
This class encapsulates execution of a single action at a time. You set the action to execute, which waits on the currently executing action and kills any pending ones.
This class can be thought of as an
Actionqueue that limits to 1 action running at a time, and if any new actions are pushed into it, the queue’s pending actions are cleared. (The actively running action will not get cancelled.)
Constructors
Methods
Constructors
- CurrentAction.constructor(suppressFailures)
Creates a new
CurrentAction.- Arguments
suppressFailures (
boolean()) –
- Return type
Methods
clear
- CurrentAction.clear()
Clears and discards any pending actions. If an action is currently being executed, it remains unaffected by this.
- Return type
void
isIdle
- CurrentAction.isIdle()
Queries the idle state of this object.
- Return type
boolean
- Returns
trueif there are no executing actions andfalseotherwise.
set
- CurrentAction.set(action)
Sets the action to execute to the one supplied.
If this object is idle, then the action is immediately executed, and this object is no longer as long as the action is running.
Otherwise if the object is not idle, then action becomes pended and will execute after the current one finishes. If an action is already pended, then the prior pending action is replaced by the newly supplied action and is discarded.
- Arguments
action (ActionLike) –
- Return type
void
If this object is idle, then the action is immediately executed, and this object is no longer as long as the action is running.
Otherwise if the object is not idle, then action becomes pended and will execute after the current one finishes. If an action is already pended, then the prior pending action is replaced by the newly supplied action and is discarded.
waitForIdle
- CurrentAction.waitForIdle()
Creates
Promisethat can be used to wait for this object to become idle.If this object was created with
suppressFailures, then the returnedPromisenever throws. Otherwise action failures (fromthis.set) propagate to the returnedPromise.- Return type
Promise <void>
- Returns
The idle
Promise.
If this object was created with
suppressFailures, then the returnedPromisenever throws. Otherwise action failures (fromthis.set) propagate to the returnedPromise.