API reference > @kontsedal/olas-core > debounced
debounced() function โ
Lag a signal by ms. The returned signal updates only after the source has been unchanged for ms. Each new write resets the timer.
leading: true(defaultfalse) emits immediately on the first write, then suppresses further writes untilmshas passed since the last emission. Combine with trailing (defaulttrue) for "first + last" semantics. -trailing: falsedisables the trailing emission. Pair withleading: truefor "only fire on the leading edge" semantics. -options.signal(AbortSignal) ties the internal effect to a lifecycle โ when the signal aborts the effect disposes, the pending timer clears, and the subscriber chain onsourcedrops.
ms goes through the shared expiry scheduler (spec ยง21.5): Infinity never fires on its own, so only flush() emits, and a window past the 32-bit timer limit waits its full length. NaN runs as 0, with a warning in development.
Signature:
typescript
export declare function debounced<T>(source: ReadSignal<T>, windowMs: number, options?: TimingOptions): TimingSignal<T>;Parameters โ
Parameter | Type | Description |
|---|---|---|
source | ReadSignal<T> | |
windowMs | number | |
options | (Optional) |
Returns:
TimingSignal<T>