
#############
CurrentAction
#############

.. js:class:: 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 ``Action`` queue  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.)
   
   
   Index
   =====
   
   .. rubric:: Constructors
   
   
   .. rst-class:: api-xref-list
   
   
   * :js:func:`~Util.CurrentAction.constructor`
   
   .. rubric:: Methods
   
   
   .. rst-class:: api-xref-list
   
   
   * :js:meth:`~Util.CurrentAction.clear`
   * :js:meth:`~Util.CurrentAction.isIdle`
   * :js:meth:`~Util.CurrentAction.set`
   * :js:meth:`~Util.CurrentAction.waitForIdle`
   
   




Constructors
============

.. js:method:: Util.CurrentAction.constructor

   .. rst-class:: sig-pretty-signature
   
      | CurrentAction(**suppressFailures**\ : *boolean*\ ): :js:class:`CurrentAction <Util.CurrentAction>`
   
   Creates a new ``CurrentAction``\ .
   
   **Parameters**
   
      **suppressFailures**\ : *boolean*
   
         Controls whether or not thrown action errors cause ``waitForIdle`` to throw.
   
   
   
   **Returns**\ : :js:class:`CurrentAction <Util.CurrentAction>`
   





Methods
=======

.. js:method:: Util.CurrentAction.clear

   .. rst-class:: sig-pretty-signature
   
      | clear(): *void*
   
   Clears and discards any pending actions. If an action is currently being executed, it remains unaffected by this.
   
   **Returns**\ : *void*
   



.. js:method:: Util.CurrentAction.isIdle

   .. rst-class:: sig-pretty-signature
   
      | isIdle(): *boolean*
   
   Queries the idle state of this object.
   
   **Returns**\ : *boolean*
   
      ``true`` if there are no executing actions and ``false`` otherwise.
   
   



.. js:method:: Util.CurrentAction.set

   .. rst-class:: sig-pretty-signature
   
      | set(**action**\ : :js:data:`ActionLike <Util.ActionLike>`\ ): *void*
   
   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.
   
   **Parameters**
   
      **action**\ : :js:data:`ActionLike <Util.ActionLike>`
   
   
   **Returns**\ : *void*
   



.. js:method:: Util.CurrentAction.waitForIdle

   .. rst-class:: sig-pretty-signature
   
      | waitForIdle(): *Promise*
   
   Creates ``Promise`` that can be used to wait for this object to become idle.
   
   If this object was created with ``suppressFailures``\ , then the returned ``Promise`` never throws. Otherwise action failures (from ``this.set``\ ) propagate to the returned ``Promise``\ .
   
   **Returns**\ : *Promise*
   
      The idle ``Promise``\ .
   
   





