Skip to content
0

katanakit-js / useDebounce

Function: useDebounce() ​

ts
function useDebounce<T>(func, delayMs): (...args) => void;

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

Returns a debounced version of func that delays invocation until delayMs milliseconds of quiet.

Type Parameters ​

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

Parameters ​

ParameterTypeDescription
funcTFunction to debounce.
delayMsnumberDebounce delay in milliseconds.

Returns ​

A debounced function with the same signature.

(...args) => void

Example ​

ts
const debouncedSearch = useDebounce(fetchResults, 300);
input.addEventListener("input", () => debouncedSearch(input.value));

Released under the MIT License.