ReferencedebounceTime
Reference · 17
debounceTime
debounceTime
Emits a value only after a pause of a given length.
Signature
debounceTime(dueTime: number, scheduler?: SchedulerLike): MonoTypeOperatorFunction
Marble diagram
in: a-b---------c-d-|
debounce(20): -------b-------d-|
What it does
On each next it resets an internal timer and starts over. If no new values arrive within dueTime, it emits the last one. If the stream completes with the timer still pending, the last value is emitted before complete too.
When to use
Typeahead/search, validating a form as the user types, resize/scroll handlers, any "do nothing until the user is done".
Gotcha
The difference from throttleTime: debounce waits for silence, while throttle lets the first value through and cuts the rest within the window.
See also
throttleTime, auditTime, distinctUntilChanged
script.ts
CONSOLE · Console output
Hit Run to see the result...