Saltar al contenido principal

Function: useDebounceImmediate()

useDebounceImmediate<T>(func, delayMs): (...args) => void

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

Leading-edge debounce: fires immediately on the first call, then ignores calls until delayMs of quiet. Additional calls during the wait window schedule a single trailing invocation with the latest arguments.

Type Parameters

T

T extends (...args) => unknown

The wrapped function type.

Parameters

func

T

Function to debounce.

delayMs

number

Debounce delay in milliseconds.

Returns

A debounced function with the same signature.

(...args) => void

Example

const save = useDebounceImmediate(submitForm, 500);
save("a"); // fires immediately
save("b"); // queued
save("c"); // queued (replaces "b")
// after 500ms of quiet: fires with "c"