Skip to content
filtering

debounceTime

Emits a value from the source only after a specified silence period has passed with no new emissions — drops all intermediate values.

Signature

debounceTime<T>(dueTime: number, scheduler?: SchedulerLike): MonoTypeOperatorFunction<T>

Marble Diagram

source:  --a-b-c-------d--|
debounceTime(2)
result:  ----------c-------d--|
(only emits after 2ms of silence)

Example

import { fromEvent } from 'rxjs'
import { debounceTime, distinctUntilChanged, map } from 'rxjs/operators'

fromEvent(searchInput, 'input').pipe(
  map(e => e.target.value),
  debounceTime(300),
  distinctUntilChanged()
).subscribe(value => searchAPI(value))
// Only fires 300ms after user stops typing

Common Use Cases

  • Delay search API calls until user stops typing
  • Prevent rapid button-click spam from triggering multiple requests
  • Throttle window resize or scroll event handlers

Flow Diagram