Class: shaka.util.Timer

Constructor

(export) new Timer(onTick)

Create a new timer. A timer is committed to a single callback function. While there is no technical reason to do this, it is far easier to understand and use timers when they are connected to one functional idea.
Parameters:
Name Type Description
onTick function
Source:

Members

(private) onTick_ :function()

Each time our timer "does work", we call that a "tick". The name comes from old analog clocks.
Type:
  • function()
Source:

(private, nullable) pendingTickId_ :number

When we schedule a timeout, it will give us an id for it. We can use this id to cancel it anytime before it executes.
Type:
  • number
Source:

Methods

(export) start(delayInSeconds, repeating)

Start the timer. The timer will tick in |delayInSeconds|. If |repeating| is |true|, the timer will keep ticking until |stop| is called. Calling |start| on a running timer will override any previous calls to |start|.
Parameters:
Name Type Description
delayInSeconds number
repeating boolean
Source:

(export) stop()

Stop the timer and cancel any pending ticks. The timer is still usable after calling |stop|.
Source:

(export) tick()

Force the timer to tick. The timer will tick synchronously. This will cancel any pending ticks (overriding previous calls to |start|).
Source: