Class for handling timing events.

Inheritance

Object
     goog.Disposable
          goog.events.EventTarget
               goog.Timer

Constructor

goog.Timer(opt_intervalopt_timerObject)

Parameters

opt_interval :
Number of ms between ticks (Default: 1ms).
opt_timerObject :
An object that has setTimeout, setInterval, clearTimeout and clearInterval (eg Window).

Instance Methods

Public Protected Private
Defined in goog.Timer
dispatchTick_()
Dispatches the TICK event. This is its own method so subclasses can override.
code »
disposeInternal()
No description.
code »
getInterval()
Gets the interval of the timer.
Returns:   interval Number of ms between ticks.
code »
setInterval(interval)
Sets the interval of the timer.
Arguments:
interval :
Number of ms between ticks.
code »
start()
No description.
code »
stop()
No description.
code »
tick_()
Callback for the setInterval used by the timer
code »
addEventListener(typehandleropt_captureopt_handlerScope)
Adds an event listener to the event target. The same handler can only be added once per the type. Even if you add the same handler multiple times using the same type then it will only be called once when the event is dispatched. Supported for legacy but use goog.events.listen(src, type, handler) instead.
Arguments:
type :
The type of the event to listen for.
handler :
The function to handle the event. The handler can also be an object that implements the handleEvent method which takes the event object as argument.
opt_capture :
In DOM-compliant browsers, this determines whether the listener is fired during the capture or bubble phase of the event.
opt_handlerScope :
Object in whose scope to call the listener.
code »
dispatchEvent(e)
Dispatches an event (or event like object) and calls all listeners listening for events of this type. The type of the event is decided by the type property on the event object. If any of the listeners returns false OR calls preventDefault then this function will return false. If one of the capture listeners calls stopPropagation, then the bubble listeners won't fire.
Arguments:
e :
Event object.
Returns:   If anyone called preventDefault on the event object (or if any of the handlers returns false this will also return false.
code »
disposeInternal()
Unattach listeners from this object. Classes that extend EventTarget may need to override this method in order to remove references to DOM Elements and additional listeners, it should be something like this:
MyClass.prototype.disposeInternal = function() {
MyClass.superClass_.disposeInternal.call(this);
// Dispose logic for MyClass
};
code »
getParentEventTarget()
Returns the parent of this event target to use for bubbling.
Returns:   The parent EventTarget or null if there is no parent.
code »
removeEventListener(typehandleropt_captureopt_handlerScope)
Removes an event listener from the event target. The handler must be the same object as the one added. If the handler has not been added then nothing is done.
Arguments:
type :
The type of the event to listen for.
handler :
The function to handle the event. The handler can also be an object that implements the handleEvent method which takes the event object as argument.
opt_capture :
In DOM-compliant browsers, this determines whether the listener is fired during the capture or bubble phase of the event.
opt_handlerScope :
Object in whose scope to call the listener.
code »
setParentEventTarget(parent)
Sets the parent of this event target to use for bubbling.
Arguments:
parent :
Parent EventTarget (null if none).
code »
dispose()
No description.
code »
disposeInternal()
Deletes or nulls out any references to COM objects, DOM nodes, or other disposable objects. Classes that extend {@code goog.Disposable} should override this method. For example:
mypackage.MyClass = function() {
goog.Disposable.call(this);
// Constructor logic specific to MyClass.
...
};
goog.inherits(mypackage.MyClass, goog.Disposable);

mypackage.MyClass.prototype.disposeInternal = function() {
mypackage.MyClass.superClass_.disposeInternal.call(this);
// Dispose logic specific to MyClass.
...
};
code »
getDisposed()
No description.
Returns:   Whether the object has been disposed of.
code »
isDisposed()
No description.
Returns:   Whether the object has been disposed of.
code »

Instance Properties

Defined in goog.Timer
enabled :
Whether this timer is enabled
Code »
timer_ :
Variable for storing the result of setInterval
Code »
customEvent_ :
Used to tell if an event is a real event in goog.events.listen() so we don't get listen() calling addEventListener() and vice-versa.
Code »
parentEventTarget_ :
Parent event target, used during event bubbling.
Code »
disposed_ :
Whether the object has been disposed of.
Code »

Static Methods

goog.Timer.callOnce(listeneropt_intervalopt_handler)
Calls the given function once, after the optional pause
Arguments:
listener :
Function or object that has a handleEvent method.
opt_interval :
Number of ms between ticks (Default: 1ms).
opt_handler :
Object in whose scope to call the listener.
Returns:   A handle to the timer ID.
code »
goog.Timer.clear(timerId)
Clears a timeout initiated by callOnce
Arguments:
timerId :
a timer ID.
code »
goog.Timer.defaultTimerObject()
No description.
code »

Static Properties

goog.Timer.MAX_TIMEOUT_ :
Maximum timeout value. Timeout values too big to fit into a signed 32-bit integer may cause overflow in FF, Safari, and Chrome, resulting in the timeout being scheduled immediately. It makes more sense simply not to schedule these timeouts, since 24.8 days is beyond a reasonable expectation for the browser to stay open.
Code »
goog.Timer.TICK :
Constant for the timer's event type
Code »
goog.Timer.intervalScale :
A variable that controls the timer error correction. If the timer is called before the requested interval times intervalScale, which often happens on mozilla, the timer is rescheduled. See also this.last_
Code »

Package Timer

Package Reference