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 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 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=
The object scope to invoke the function in.

Instance Methods

Public Protected Private
disposeInternal()
No description.
code »
isActive() boolean
No description.
Returns: boolean  True if the delay is currently active, false otherwise.
code »
isDone() boolean
No description.
Returns: boolean  True if the listener has been executed and returned true since the last call to .
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 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 method is invoked. If the timeout is exceeded the delay is stopped and the 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=
The time interval between the function invocations (in milliseconds). Default is 0.
opt_timeout : number=
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 »
addOnDisposeCallback(callbackopt_scope)
Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added.
Arguments:
callback : function(this:T):?
The callback function.
opt_scope : T=
An optional scope to call the callback in.
code »
dispose() void
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: void  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() {
    mypackage.MyClass.base(this, 'constructor');
    // Constructor logic specific to MyClass.
    ...
  };
  goog.inherits(mypackage.MyClass, goog.Disposable);

  mypackage.MyClass.prototype.disposeInternal = function() {
    // Dispose logic specific to MyClass.
    ...
    // Call superclass's disposeInternal at the end of the subclass's, like
    // in C++, to avoid hard-to-catch issues.
    mypackage.MyClass.base(this, 'disposeInternal');
  };
code »
getDisposed() boolean
Use #isDisposed instead. No description.
Returns: boolean  Whether the object has been disposed of.
code »
isDisposed() boolean
No description.
Returns: boolean  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 : goog.disposable.IDisposable
that will be disposed when this object is disposed.
code »

Instance Properties

constructor :
No description.
Code »
delay_ : goog.async.Delay
The underlying goog.async.Delay delegate object.
Code »
handler_ :
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 »
creationStack :
If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.
Code »
disposed_ :
Whether the object has been disposed of.
Code »
onDisposeCallbacks_ :
Callbacks to invoke when this object is disposed.
Code »

Static Properties

goog.async.ConditionalDelay.superClass_ :
No description.
Code »

Package async

Package Reference