Skip to content
0

katanakit-js / useThrottle

Function: useThrottle() ​

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

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

Returns a throttled version of func that fires at most once per limitMs milliseconds (leading edge).

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 throttledScroll = useThrottle(onScroll, 100);
window.addEventListener("scroll", throttledScroll);

Released under the MIT License.