O'Reilly logo

Mastering Reactive JavaScript by Erich de Souza Oliveira

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The debounce() operator

The next lossy technique for backpressure is the usage of the debounce() operator. This operator emits data from the observable only after a certain interval when the last emission from this observable has passed.

This method is really useful to implement features such as search-as-you-type, as we might not want to call our server for every keystroke from the user. Using this method, we can let the user keep typing and search only when the user stays a few milliseconds without typing anything.

The debounce() operator has the following signature:

observable.debounce(interval,[scheduler]); 

The first parameter is mandatory and the second is optional:

  • interval: This is the time to wait in milliseconds
  • scheduler: This ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required