goog.async.Throttle
Classgoog.async.Throttle
> goog.Disposable
goog.async.Throttle(listener, interval, opt_handler)
Throttle will perform an action that is passed in no more than once per interval (specified in milliseconds). If it gets multiple signals to perform the action while it is waiting, it will only perform the action once at the end of the interval.
listener
{Function
}
interval
{number
}
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. ... };
.fire()
Notifies the throttle that the action has happened. It will throttle the call so that the callback is not called too often according to the interval parameter passed to the constructor.
.getDisposed
[deprecated]Deprecated. Use {@link #isDisposed} instead.
Inherited from goog.Disposable
.
boolean
}
.isDisposed()
Inherited from goog.Disposable
.
boolean
}
.pause()
Pauses the throttle. All pending and future action callbacks will be delayed until the throttle is resumed. Pauses can be nested.
.registerDisposable(disposable)
Inherited from goog.Disposable
.
Associates a disposable object with this object so that they will be disposed together.
disposable
{goog.disposable.IDisposable
}
.resume()
Resumes the throttle. If doing so drops the pausing count to zero, pending action callbacks will be executed as soon as possible, but still no sooner than an interval's delay after the previous call. Future action callbacks will be executed as normal.
.stop()
Cancels any pending action callback. The throttle can be restarted by calling {@link #fire}.