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 throttle() operator

The first lossy technique to deal with backpressure is the throttle() operator. This operator lets you propagate the elements emitted by the observable at a certain interval.

This operator is perfect for implementing rate limiting, such as the problem of showing tweets as fast as a human can read.

The throttle() operator has the following signature:

observable.throttle(interval,[scheduler]); 

The first parameter is mandatory and the second is optional:

  • interval: This is the time interval, in milliseconds, between the emission of data
  • scheduler: This is used to propagate the data

The easiest way to show the usage of this operator is to apply it on an observable that already emits elements at a certain rate. We can ...

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