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.
extends goog.Disposable| Instance Method Summary | |
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. 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.
...
};
| |
isActive() ⇒ 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. | |
onTick_()A callback function for the underlying {@code goog.async.Delay} object. When executed the listener function is called, and if it returns {@code true} the delay is stopped and the {@see #onSuccess} method is invoked. If the timeout is exceeded the delay is stopped and the {@see #onFailure} method is called. | |
start(number= opt_interval, number= 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. | |
stop()Stops the delay timer if it is active. No action is taken if the timer is not in use. | |