ThrottledFunction
Throttles execution of a function with configurable leading and trailing behavior.
Functions
new
ThrottledFunction.new(timeoutInSeconds: number,--
The (minimum) time in seconds to wait between each function dispatch; the "cooldown".
func: function,--
The actual function whose calls will be throttled.
) → ThrottledFunction<T...>Types
interface ThrottleConfig {leading: boolean?--
If true, will dispatch immediately after creating this ThrottledFunction.
trailing: boolean?--
If true, will dispatch after the timeout with the latest-called args.
leadingFirstTimeOnly: boolean?--
If true, will dispatch immediately after creating this ThrottledFunction, but from then on, will begin the window upon manual call and delay dispatch until seconds have passed (with latest-called args).
}Call
ThrottledFunction.Call() → ()If leading = true, will enable Call() dispatching immediately after creating this ThrottledFunction. Else, will have to wait seconds before it dispatches with the latest-called args.
If trailing = true, will dispatch after the timeout with the latest-called args. Else, will not automatically dispatch, and must manually call again after seconds.
If leadingFirstTimeOnly = true, will enable Call() dispatching immediately after creating this ThrottledFunction, but from then on, will begin the window upon manual call and delay dispatch until seconds have passed (with latest-called args).
Destroy
ThrottledFunction.Destroy() → ()Cancels any pending trailing calls.