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(defaulttrue) skips the immediate leading-edge emission. Useful for "fire only after the window settles" semantics. -trailing: false(defaulttrue) skips the windowed trailing emit. Combine withleading: truefor "only fire on the leading edge." -options.signalties 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 | (Optional) |
Returns:
TimingSignal<T>