Throttle

Throttle

new Throttle(delayopt)

Throttle class. Throttles function invocations.
Parameters:
Name Type Attributes Description
delay number <optional>
The delay before invocation. Default value is 1 second.

Methods

cancel() → {boolean}

Cancels any delayed invocation.
Returns:
true if cancelation occured, false if there was no delayed invocation to cancel.
Type
boolean

canceledBy(fn, contextopt)

Returns anonymous function which either cancels delayed invocation of throttled function, or invokes given function.
Parameters:
Name Type Attributes Description
fn function The function to invoke.
context Object <optional>
The object to which the context "this" of the function should be set.

of(fn, contextopt)

Returns anonymous function which performs delayed function invocation.
Parameters:
Name Type Attributes Description
fn function The function to invoke.
context Object <optional>
The object to which the context "this" of the function should be set.