Skip to content

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 (default false) emits immediately on the first write, then suppresses further writes until ms has passed since the last emission. Combine with trailing (default true) for "first + last" semantics. - trailing: false disables the trailing emission. Pair with leading: true for "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 on source drops.

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

TimingOptions

(Optional)

Returns:

TimingSignal<T>

Released under the MIT License.