Skip to content

API reference > @kontsedal/olas-core > throttled

throttled() function ​

Rate-limit a signal so it emits at most once per ms (leading + trailing). The first change passes through immediately. Subsequent changes within the window are coalesced; the latest value is emitted when the window expires.

  • leading: false (default true) skips the immediate leading-edge emission. Useful for "fire only after the window settles" semantics. - trailing: false (default true) skips the windowed trailing emit. Combine with leading: true for "only fire on the leading edge." - options.signal ties the internal effect to a lifecycle.

The returned handle exposes cancel() / flush() — see TimingSignal.ms goes through the shared expiry scheduler, as in debounced: withInfinity, only the leading edge and flush() emit. NaN runs as 0, with a warning in development.

Signature:

typescript
export declare function throttled<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.