Skip to content
PACKAGES

debounce()

debounce (alias debounceTime): emit the latest value only after ms of quiet. switchMap cancels the prior timer (its onDeactivation clearTimeout) on each new source value and restarts — the declarative debounce.

RxJS-7 divergence (reference [email protected], B44): RxJS debounceTime FLUSHES the pending value IMMEDIATELY when the source COMPLETEs (its _complete calls debouncedNext() before complete()). This composition instead emits the pending value when the in-flight timer(ms) fires — i.e. at (last-value-time + ms) — so if the source completes mid-window the trailing value arrives up to ms later than RxJS. Inherent to the *Map+timer form (the composition cannot flush early without detecting COMPLETE inside the switchMap inner); accepted, not a bug.

import { debounce } from "@graphrefly/ts/operators";
function debounce(ms: number): Operator<S, S>
ParameterTypeDescription
msnumberDuration or timestamp in milliseconds.

A Operator<S, S> value.

import { debounce } from "@graphrefly/ts/operators";

packages/ts/src/graph/time.ts