Skip to content
Reactivity

useThrottled

Throttle an Observable value. Creates a read-only Observable that updates at most once per interval when the source value changes.

Throttled input

Type to see the throttled value update at most every 500ms.

Source
Throttled (500ms)
import {
import useObservable
useObservable
,
import useThrottled
useThrottled
} from "@usels/web";
function
function Component(): void
Component
() {
const
const source$: any
source$
=
import useObservable
useObservable
("hello");
const
const throttled$: any
throttled$
=
import useThrottled
useThrottled
(
const source$: any
source$
, {
ms: number
ms
: 300 });
// throttled$.get() updates at most once per 300ms
}
import { useObservable, useThrottled } from "@usels/web";
function Component() {
const source$ = useObservable("hello");
// Updates immediately on change, suppresses further updates within interval
const throttled$ = useThrottled(source$, { ms: 300, edges: ["leading"] });
}
import { useObservable, useThrottled } from "@usels/web";
function Component() {
const source$ = useObservable("hello");
// Does not update immediately — updates once after the interval ends
const throttled$ = useThrottled(source$, { ms: 300, edges: ["trailing"] });
}
ParameterTypeDescription
source$Observable<T>Source Observable to throttle.
optionsThrottledOptions (optional)Throttle configuration (ms, edges).
OptionTypeDefaultDescription
msnumber200Throttle interval in milliseconds.
edges("leading" | "trailing")[]--

ReadonlyObservable<T>

A ReadonlyObservable that reflects the throttled source value.

View on GitHub