async.ConditionalDelay Extends goog.Disposable
A ConditionalDelay object invokes the associated function after a specified interval delay and checks its return value. If the function returns true the conditional delay is cancelled and #onSuccess is called. Otherwise this object keeps to invoke the deferred function until either it returns true or the timeout is exceeded. In the latter case the #onFailure method will be called. The interval duration and timeout can be specified each time the delay is started. Calling start on an active delay will reset the timer.

Inheritance

Constructor

goog.async.ConditionalDelay(listeneropt_handler)

Parameters

listener :
function (): boolean
Function to call when the delay completes. Should return a value that type-converts to true if the call succeeded and this delay should be stopped.
opt_handler :
(Object | null | undefined)
The object scope to invoke the function in.

Instance Methods

Public Protected Private
disposeInternal()
No description.
code »
isActive()
No description.
Returns:   True if the delay is currently active, false otherwise.
code »
isDone()
No description.
Returns:   True if the listener has been executed and returned true since the last call to #start.
code »
listener_()
The function that will be invoked after a delay.
code »
onFailure()
Called when this delayed call is cancelled because the timeout has been exceeded, and the listener has never returned true. Designed for inheritance, should be overridden by subclasses or on the instances if they care.
code »
onSuccess()
Called when the listener has been successfully executed and returned true. The #isDone method should return true by now. Designed for inheritance, should be overridden by subclasses or on the instances if they care.
code »
onTick_()
A callback function for the underlying goog.async.Delay object. When executed the listener function is called, and if it returns true the delay is stopped and the #onSuccess method is invoked. If the timeout is exceeded the delay is stopped and the #onFailure method is called.
code »
start(opt_intervalopt_timeout)
Starts the delay timer. The provided listener function will be called repeatedly after the specified interval until the function returns true or the timeout is exceeded. Calling start on an active timer will stop the timer first.
Arguments:
opt_interval :
(number | undefined)
The time interval between the function invocations (in milliseconds). Default is 0.
opt_timeout :
(number | undefined)
The timeout interval (in milliseconds). Takes precedence over the opt_interval, i.e. if the timeout is less than the invocation interval, the function will be called when the timeout is exceeded. A negative value means no timeout. Default is 0.
code »
stop()
Stops the delay timer if it is active. No action is taken if the timer is not in use.
code »
dispose()
undefined
Disposes of the object. If the object hasn't already been disposed of, calls #disposeInternal. Classes that extend goog.Disposable should override #disposeInternal in order to delete references to COM objects, DOM nodes, and other disposable objects. Reentrant.
Returns: 
undefined
  Nothing.
code »
disposeInternal()
Deletes or nulls out any references to COM objects, DOM nodes, or other disposable objects. Classes that extend goog.Disposable should override this method. Not reentrant. To avoid calling it twice, it must only be called from the subclass' disposeInternal method. Everywhere else the public dispose method must be used. For example:
mypackage.MyClass = function() {
goog.base(this);
// Constructor logic specific to MyClass.
...
};
goog.inherits(mypackage.MyClass, goog.Disposable);

mypackage.MyClass.prototype.disposeInternal = function() {
goog.base(this, 'disposeInternal');
// Dispose logic specific to MyClass.
...
};
code »
getDisposed()
Use #isDisposed instead. No description.
Returns:   Whether the object has been disposed of.
code »
isDisposed()
No description.
Returns:   Whether the object has been disposed of.
code »
registerDisposable(disposable)
Associates a disposable object with this object so that they will be disposed together.
Arguments:
disposable :
that will be disposed when this object is disposed.
code »

Instance Properties

delay_ :
(goog.async.Delay | null)
The underlying goog.async.Delay delegate object.
Code »
handler_ :
(Object | null | undefined)
The object context to invoke the callback in.
Code »
interval_ :
The delay interval in milliseconds to between the calls to the callback. Note, that the callback may be invoked earlier than this interval if the timeout is exceeded.
Code »
isDone_ :
True if the listener has been executed, and it returned true.
Code »
runUntil_ :
The timeout timestamp until which the delay is to be executed. A negative value means no timeout.
Code »
dependentDisposables_ :
(Array | null)
Disposables that should be disposed when this object is disposed.
Code »
disposed_ :
Whether the object has been disposed of.
Code »

Package async

Package Reference