The goog.async.Throttle Class

goog.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}
Function to callback when the action is triggered.
interval {number}
Interval over which to throttle. The handler can only be called once per interval.
opt_handler {Object=}
Object in whose scope to call the listener.

.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}
The callback function.
opt_scope {Object=}
An optional scope to call the callback in.

.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.

returns {void}
Nothing.

.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.

.isDisposed()

Inherited from goog.Disposable .

returns {boolean}
Whether the object has been disposed of.

.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}
that will be disposed when this object is disposed.

.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}.