Constructor
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
activeTimers :Map<!shaka.util.Timer, string>
Tracks all active timer instances, along with the stack trace that created
that timer.
Type:
- Map<!shaka.util.Timer, string>
- Source:
cancelPending_ :?function()
When we schedule a timeout, this callback cancels it.
Type:
- ?function()
- Source:
onTick_ :function()
Each time our timer "does work", we call that a "tick". The name comes
from old analog clocks.
Type:
- function()
- Source:
Methods
schedule_(callback, delayInSeconds)
Schedule |callback| to be called after |delayInSeconds|. If there is
already a pending call, it will be canceled first.
Parameters:
| Name | Type | Description |
|---|---|---|
callback |
function() | |
delayInSeconds |
number |
- Source:
scheduleRepeating_(seconds)
Schedule |onTick_| to be called repeatedly every |seconds|.
Parameters:
| Name | Type | Description |
|---|---|---|
seconds |
number |
- Source:
stop()
Stop the timer and clear the previous behaviour. The timer is still usable
after calling |stop|.
- Source:
tickAfter(seconds) → {shaka.util.Timer}
Have the timer call |onTick| after |seconds| has elapsed unless |stop| is
called first.
Parameters:
| Name | Type | Description |
|---|---|---|
seconds |
number |
- Source:
Returns:
- Type
- shaka.util.Timer
tickEvery(seconds) → {shaka.util.Timer}
Have the timer call |onTick| every |seconds| until |stop| is called.
Parameters:
| Name | Type | Description |
|---|---|---|
seconds |
number |
- Source:
Returns:
- Type
- shaka.util.Timer
tickNow() → {shaka.util.Timer}
Have the timer call |onTick| now.
- Source:
Returns:
- Type
- shaka.util.Timer