goog.async.ConditionalDelay
Classgoog.async.ConditionalDelay
> goog.Disposable
goog.async.ConditionalDelay(listener, opt_handler)
A ConditionalDelay object invokes the associated function after a specified interval delay and checks its return value. If the function returns {@code true} the conditional delay is cancelled and {@see #onSuccess} is called. Otherwise this object keeps to invoke the deferred function until either it returns {@code true} or the timeout is exceeded. In the latter case the {@see #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.
listener
{function
():boolean
}
opt_handler
{Object
=}
.addOnDisposeCallback(callback, opt_scope)
Inherited from goog.Disposable
.
Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added.
callback
{!Function
}
opt_scope
{Object
=}
.creationStack
{string
}Inherited from goog.Disposable
.
If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.
.dispose()
Inherited from goog.Disposable
.
Disposes of the object. If the object hasn't already been disposed of, calls {@link #disposeInternal}. Classes that extend {@code goog.Disposable} should override {@link #disposeInternal} in order to delete references to COM objects, DOM nodes, and other disposable objects. Reentrant.
void
}
.disposeInternal()
[protected]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. Not reentrant. To avoid calling it twice, it must only be called from the subclass' {@code disposeInternal} method. Everywhere else the public {@code 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. ... };
.getDisposed
[deprecated]Deprecated. Use {@link #isDisposed} instead.
Inherited from goog.Disposable
.
boolean
}
.isActive()
boolean
}
.isDisposed()
Inherited from goog.Disposable
.
boolean
}
.isDone()
boolean
}
.onFailure()
Called when this delayed call is cancelled because the timeout has been exceeded, and the listener has never returned {@code true}. Designed for inheritance, should be overridden by subclasses or on the instances if they care.
.onSuccess()
Called when the listener has been successfully executed and returned {@code true}. The {@see #isDone} method should return {@code true} by now. Designed for inheritance, should be overridden by subclasses or on the instances if they care.
.registerDisposable(disposable)
Inherited from goog.Disposable
.
Associates a disposable object with this object so that they will be disposed together.
disposable
{goog.disposable.IDisposable
}
.start(opt_interval, opt_timeout)
Starts the delay timer. The provided listener function will be called repeatedly after the specified interval until the function returns {@code true} or the timeout is exceeded. Calling start on an active timer will stop the timer first.
opt_interval
{number
=}
opt_timeout
{number
=}
.stop()
Stops the delay timer if it is active. No action is taken if the timer is not in use.