Skip to content
0

katanakit-js / useThrottleTrailing

Function: useThrottleTrailing() ​

ts
function useThrottleTrailing<T>(func, limitMs): (...args) => void;

Defined in: src/core/services/timing.service.ts:285

Throttle with trailing invocation: fires on the leading edge and also fires once at the end of the throttle window with the latest arguments.

Type Parameters ​

Type ParameterDescription
T extends (...args) => unknownThe wrapped function type.

Parameters ​

ParameterTypeDescription
funcTFunction to throttle.
limitMsnumberMinimum interval between invocations in milliseconds.

Returns ​

A throttled function with the same signature.

(...args) => void

Example ​

ts
const throttledResize = useThrottleTrailing(onResize, 200);
window.addEventListener("resize", throttledResize);

Released under the MIT License.