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
Section titled “Import”import { debounce } from "@graphrefly/ts/operators";Signature
Section titled “Signature”function debounce(ms: number): Operator<S, S>Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
ms | number | Duration or timestamp in milliseconds. |
Returns
Section titled “Returns”A Operator<S, S> value.
Example
Section titled “Example”import { debounce } from "@graphrefly/ts/operators";Source
Section titled “Source”packages/ts/src/graph/time.ts