API Docs for:
Show:

Y.Timer Class

Extends Y.Base
Defined in: js/timer.js:8
Module: timer

Losely modeled after AS3's Timer class. Provides a simple interface start, pause, resume, and stop a defined timer set with a custom callback method.

Methods

_defPauseFn

() protected

Defined in js/timer.js:312

Available since 1.0.0

Default function for pause event.

_defResumeFn

() protected

Defined in js/timer.js:324

Available since 1.0.0

Default function for resume event. Starts timer with remaining time left after Timer was paused.

_defStartFn

() protected

Defined in js/timer.js:276

Available since 1.0.0

Default function for start event.

_defStopFn

() protected

Defined in js/timer.js:298

Available since 1.0.0

Default function for stop event.

_destroyTimer

() protected

Defined in js/timer.js:202

Available since 1.0.0

Resets the Timer.

_executeCallback

() protected

Defined in js/timer.js:350

Available since 1.1.0

Used to fire the internal callback

_makeTimer

() protected

Defined in js/timer.js:171

Available since 1.0.0

Checks to see if a new Timer is to be created. If so, calls _timer() after a the schedule number of milliseconds. Sets Timer pointer to the new Timer id. Sets start to the current timestamp.

_remainingGetter

() protected

Defined in js/timer.js:365

Available since 1.2.0

Returns the time from now if the timer is running and returns remaining time from stop if the timer has stopped.

_repeatCountValidator

() protected

Defined in js/timer.js:337

Available since 1.1.0

Abstracted the repeatCount validator into the prototype to encourage class extension.

_statusChanged

()

Defined in js/timer.js:255

Available since 1.0.0

Internal status change event callback. Allows status changes to fire start(), pause(), resume(), and stop() automatically.

_timer

() protected

Defined in js/timer.js:227

Available since 1.0.0

Increments the step and either stops or starts a new Timer interval. Fires the timer callback method.

initializer

(
  • config
)
protected

Defined in js/timer.js:67

Available since 1.0.0

Initializer lifecycle implementation for the Timer class. Publishes events and subscribes to update after the status is changed.

Parameters:

  • config Object

    Configuration object literal for the Timer

pause

() public

Defined in js/timer.js:118

Available since 1.0.0

Interface method to pause the Timer. Fires timer:pause

resume

() public

Defined in js/timer.js:134

Available since 1.0.0

Interface method to resume the Timer. Fires timer:resume

start

() public

Defined in js/timer.js:86

Available since 1.0.0

Interface method to start the Timer. Fires timer:start

stop

() public

Defined in js/timer.js:102

Available since 1.0.0

Interface method to stop the Timer. Fires timer:stop

Properties

_remainingLength

Unknown protected

Defined in js/timer.js:162

Available since 1.2.0

Resume length

_timerObj

Y.later protected

Defined in js/timer.js:153

Available since 1.0.0

Internal timer

ATTRS

Object static

Defined in js/timer.js:388

Static property used to define the default attribute configuration for the Timer.

Timer.EVENTS

Object static

Defined in js/timer.js:538

Static property provides public access to registered timer event strings

Timer.STATUS

Object static

Defined in js/timer.js:524

Static property provides public access to registered timer status strings

Attributes

callback

Function

Defined in js/timer.js:398

Available since 1.0.0

The callback method that fires when the timer interval is reached.

length

Number

Defined in js/timer.js:411

Available since 1.0.0

Time in milliseconds between intervals

remaining

Number

Defined in js/timer.js:425

Available since 1.2.0

Get remaining milliseconds

repeatCount

Number

Defined in js/timer.js:437

Available since 1.1.0

Number of times the Timer should fire before it stops - 1.1.0 - added lazyAdd false to prevent starting from overriding the validator

start

Boolean

Defined in js/timer.js:454

Available since 1.0.0

Timestamp Timer was started

startDelay

Number

Defined in js/timer.js:465

Available since 1.1.0

Time in ms to wait until starting after start() has been called

status

String

Defined in js/timer.js:475

Available since 1.1.0

Timer status - 1.1.0 - Changed from state to status. state was left from legacy code

Default: STATUS_STOPPED

step

Boolean

Defined in js/timer.js:489

Available since 1.0.0

Number of times the Timer has looped

stop

Boolean

Defined in js/timer.js:501

Available since 1.0.0

Timestamp Timer was stoped or paused

timer

Number

Defined in js/timer.js:512

Available since 1.0.0

Timer id to used during stop()

Events

pause

Event.Custom

Defined in js/timer.js:43

The timer has paused

Event Payload:

  • event Event.Facade

    An Event Facade object

resume

Event.Custom

Defined in js/timer.js:50

The timer has resumed

Event Payload:

  • event Event.Facade

    An Event Facade object

start

Event.Custom

Defined in js/timer.js:29

The timer has started

Event Payload:

  • event Event.Facade

    An Event Facade object

stop

Event.Custom

Defined in js/timer.js:36

The timer has stopped

Event Payload:

  • event Event.Facade

    An Event Facade object

timer

Event.Custom

Defined in js/timer.js:57

The timer has reached a reached zero

Event Payload:

  • event Event.Facade

    An Event Facade object