Class: KeyedDebounce<T>
Defined in: throttle.ts:367 Per-key debounce manager — wraps debounce with aMap keyed
by user-supplied identifiers so different keys debounce
independently.
Typical use: per-input search-as-you-type, per-form auto-save,
per-resource validation. Memory grows with the number of distinct
keys; call cancel, flush, or cancelAll to
release resources.
Example
Type Parameters
T
T extends AnyFunction
Function being debounced.
Constructors
Constructor
new KeyedDebounce<Defined in: throttle.ts:383T>(func,wait,options?):KeyedDebounce<T>
Parameters
func
T
Function to debounce. The same instance is used for
every key.
wait
number
Quiet window in milliseconds before firing.
options?
Forwarded to debounce for each key’s internal debounced wrapper.leading?
boolean
maxWait?
number
Returns
KeyedDebounce<T>
Methods
cancel()
cancel(Defined in: throttle.ts:408 Cancel any pending fire forkey):void
key and drop the bucket from the map.
The next execute(key, …) will start fresh.
Parameters
key
string
Returns
void
cancelAll()
cancelAll(): void
Defined in: throttle.ts:432
Cancel and drop every bucket.
Returns
void
execute()
execute(Defined in: throttle.ts:393 Push a new call forkey, …args):void
key, lazily creating the debounce bucket on
first invocation. Resets the quiet timer for that key.
Parameters
key
string
args
…Parameters<T>
Returns
void
flush()
flush(Defined in: throttle.ts:424 Cancel any pending timer forkey):void
key without firing it. The bucket
stays alive — future execute(key, …) calls are still debounced.
(The wrapped debounce(...).flush() from this implementation
cancels rather than forces — see the debounce source for
specifics.)
Parameters
key
string
Returns
void
getStats()
getStats(): object
Defined in: throttle.ts:445
Snapshot of currently-tracked keys.
Returns
object
{ activeKeys, keys }. The keys array is a one-shot
copy and not kept in sync with future mutations.
activeKeys
activeKeys: number
keys
keys: readonly string[]