useThrottled
Throttle an Observable value. Creates a read-only Observable that updates at most once per interval when the source value changes.
Source:
Throttled (500ms):
import { function useObservable<T>(): Observable<T | undefined> (+3 overloads)
A React hook that creates a new observable
useObservable } from "@legendapp/state/react";import { import useThrottled
useThrottled } from "@usels/web";
const const source$: any
source$ = useObservable<unknown>(value: Promise<unknown> | (() => unknown) | unknown, deps?: React.DependencyList): any (+3 overloads)
A React hook that creates a new observable
useObservable("hello");const const throttled$: any
throttled$ = import useThrottled
useThrottled(const source$: any
source$, 300);// throttled$.get() updates at most once per 300msWith reactive delay:
import { function useObservable<T>(): Observable<T | undefined> (+3 overloads)
A React hook that creates a new observable
useObservable } from "@legendapp/state/react";import { import useThrottled
useThrottled } from "@usels/web";
const const source$: any
source$ = useObservable<unknown>(value: Promise<unknown> | (() => unknown) | unknown, deps?: React.DependencyList): any (+3 overloads)
A React hook that creates a new observable
useObservable(0);const const delay$: any
delay$ = useObservable<unknown>(value: Promise<unknown> | (() => unknown) | unknown, deps?: React.DependencyList): any (+3 overloads)
A React hook that creates a new observable
useObservable(300);const const throttled$: any
throttled$ = import useThrottled
useThrottled(const source$: any
source$, const delay$: any
delay$);// Changing delay$ applies from the next throttle cycleLeading edge only
Section titled “Leading edge only”import { function useObservable<T>(): Observable<T | undefined> (+3 overloads)
A React hook that creates a new observable
useObservable } from "@legendapp/state/react";import { import useThrottled
useThrottled } from "@usels/web";
const const source$: any
source$ = useObservable<unknown>(value: Promise<unknown> | (() => unknown) | unknown, deps?: React.DependencyList): any (+3 overloads)
A React hook that creates a new observable
useObservable("hello");// Updates immediately on change, suppresses further updates within intervalconst const throttled$: any
throttled$ = import useThrottled
useThrottled(const source$: any
source$, 300, { edges: {}
edges: ["leading"] });Trailing edge only
Section titled “Trailing edge only”import { function useObservable<T>(): Observable<T | undefined> (+3 overloads)
A React hook that creates a new observable
useObservable } from "@legendapp/state/react";import { import useThrottled
useThrottled } from "@usels/web";
const const source$: any
source$ = useObservable<unknown>(value: Promise<unknown> | (() => unknown) | unknown, deps?: React.DependencyList): any (+3 overloads)
A React hook that creates a new observable
useObservable("hello");// Does not update immediately — updates once after the interval endsconst const throttled$: any
throttled$ = import useThrottled
useThrottled(const source$: any
source$, 300, { edges: {}
edges: ["trailing"] });Type Declarations
Section titled “Type Declarations”export declare function useThrottled<T>(value: MaybeObservable<T>, ms?: MaybeObservable<number>, options?: ThrottleFilterOptions): ReadonlyObservable<T>;Source
Section titled “Source”Contributors
Section titled “Contributors”- tigerwest
Changelog
Section titled “Changelog”a7392ab2026-03-06 - feat(core,browser): add sync strategy hooks (tigerwest)