Efficient-angular
GitHubToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeBack to homepage

DebounceTime

Emits a notification from the source Observable only after a particular time span has passed without another source emission.

Syntax

debounceTime<T>(dueTime: number, scheduler: SchedulerLike = asyncScheduler): MonoTypeOperatorFunction<T>
ParametersDescription
dueTimeThe timeout duration in milliseconds (or the time unit determined internally by the optional scheduler) for the window of time required to wait for emission silence before emitting the most recent source value.
scheduler optionalDefault is asyncScheduler. The SchedulerLike to use for managing the timers that handle the timeout for each value.

Returns

MonoTypeOperatorFunction: A function that returns an Observable that delays the emissions of the source Observable by the specified dueTime, and may drop some values if they occur too frequently.

Example

Emit the most recent click after a burst of clicks

import { fromEvent } from 'rxjs';
import { debounceTime } from 'rxjs/operators';

const clicks = fromEvent(document, 'click');
const result = clicks.pipe(debounceTime(1000));
result.subscribe(x => console.log(x));