debounceTime

accepts 1 input stream, time period number

  • Whenever an event is emitted, the time period of silence measured restarts from zero
  • It waits for a time period of silence and then emits the latest value of the input stream

returns a new stream of debounced values

throttleTime

accepts 1 input stream, time period number

  • It starts by emitting the first values of the input stream
  • Then, it limits the rate of values to at most one per time period

returns a new stream of throttled values

Published on Monday, 11 Dec. 2017
Revised on Monday, 8 Oct. 2018

debounceTime vs throttleTime in RxJS

If your stream is created from key presses or mouse movements, you’ll likely deal with bursts of events. But you can’t react to every single event, as it would overload the CPU or flood the servers with too many requests.

❚ debounceTime rate-limits events, based on an “emission silence” window of time. ❚ throttleTime doesn’t delay events.

They both accept a time period argument, such as 500 milliseconds.

See also


The JavaScript pipeline operator proposal

Subscribe to reactive.how newsletter

Receive my latest news, tips and animations:

Learn Reactive Programming and stay up-to-date:
Cédric Soulas

Freelance Developer Advocate. Motion graphics with code. JavaScript and Elm. cedricsoulas.com