Y.Timer Class
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.
Item Index
Methods
Properties
- _remainingLength
- _timerObj
- ATTRS static
- Timer.EVENTS static
- Timer.STATUS static
Attributes
Methods
_defPauseFn
()
protected
Default function for pause event.
_defResumeFn
()
protected
Default function for resume event. Starts timer with remaining time left after Timer was paused.
_defStartFn
()
protected
Default function for start event.
_defStopFn
()
protected
Default function for stop event.
_destroyTimer
()
protected
Resets the Timer.
_executeCallback
()
protected
Used to fire the internal callback
_makeTimer
()
protected
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
Returns the time from now
if the timer is running and returns remaining
time from stop
if the timer has stopped.
_repeatCountValidator
()
protected
Abstracted the repeatCount validator into the prototype to encourage class extension.
_statusChanged
()
Internal status change event callback. Allows status changes to fire start(), pause(), resume(), and stop() automatically.
_timer
()
protected
Increments the step and either stops or starts a new Timer interval. Fires the timer callback method.
initializer
-
config
Initializer lifecycle implementation for the Timer class. Publishes events and subscribes to update after the status is changed.
Parameters:
-
config
ObjectConfiguration object literal for the Timer
pause
()
public
Interface method to pause the Timer. Fires timer:pause
resume
()
public
Interface method to resume the Timer. Fires timer:resume
start
()
public
Interface method to start the Timer. Fires timer:start
stop
()
public
Interface method to stop the Timer. Fires timer:stop
Properties
_remainingLength
Unknown
protected
Resume length
_timerObj
Y.later
protected
Internal timer
ATTRS
Object
static
Static property used to define the default attribute configuration for the Timer.
Timer.EVENTS
Object
static
Static property provides public access to registered timer event strings
Timer.STATUS
Object
static
Static property provides public access to registered timer status strings
Attributes
repeatCount
Number
Number of times the Timer should fire before it stops - 1.1.0 - added lazyAdd false to prevent starting from overriding the validator
Events
pause
Event.Custom
The timer has paused
Event Payload:
-
event
Event.FacadeAn Event Facade object
resume
Event.Custom
The timer has resumed
Event Payload:
-
event
Event.FacadeAn Event Facade object
start
Event.Custom
The timer has started
Event Payload:
-
event
Event.FacadeAn Event Facade object
stop
Event.Custom
The timer has stopped
Event Payload:
-
event
Event.FacadeAn Event Facade object
timer
Event.Custom
The timer has reached a reached zero
Event Payload:
-
event
Event.FacadeAn Event Facade object