.. role:: ts-api-decorator

#####
Timer
#####

.. js:module:: Util
   :noindex:

.. container:: ts-api-section

   .. js:class:: Timer

      This class represents a single time-delayed action.



.. container:: api-index-section

   .. rubric:: Constructors

   .. rst-class:: api-index-list-item api-kind-constructor api-parent-kind-class

   * :js:meth:`~Util.Timer.constructor`



.. container:: api-index-section

   .. rubric:: Methods

   .. rst-class:: api-index-list-item api-kind-method api-parent-kind-class

   * :js:meth:`~Util.Timer.clear`
   * :js:meth:`~Util.Timer.isIdle`
   * :js:meth:`~Util.Timer.set`
   * :js:meth:`~Util.Timer.waitForIdle`





------------

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

.. container:: ts-api-section

   .. js:function:: Timer.constructor()



      :rtype: Timer



Methods
=======

.. rst-class:: ts-api-section

clear
-----

.. js:method:: Timer.clear()



   Clears the pending action if it exists.


   :rtype: void

.. rst-class:: ts-api-section

isIdle
------

.. js:method:: Timer.isIdle( type)

   :param type: None
   :type type: TimerIdleType


   Returns true if no pending action exists and false otherwise.


   :rtype: boolean

.. rst-class:: ts-api-section

set
---

.. js:method:: Timer.set( delay, action)

   :param delay: The delay in milliseconds to pend the action.
   :type delay: number
   :param action: The action to pend.
   :type action: function


   Sets a new delayed action. If one is already pending before this call is made, it gets cleared.


   :rtype: void




   .. js:function:: action()
      :noindex:



      :rtype: void



.. rst-class:: ts-api-section

waitForIdle
-----------

.. js:method:: Timer.waitForIdle( type)

   :param type: None
   :type type: TimerIdleType


   Returns a promise that resolves when the timer becomes (or already is) idle.


   :rtype: Promise <void>

