In RxJS we have several operators which can be used to mitigate the backpressure problem, they belong to two different family of strategies the lossy and the loss-less strategies. We will see each one in detail in this chapter.
Lossy strategies to deal with backpressure are the ones we must use when we want to discard some data. As we discussed, you might not be interested in all the movements from your user mouse.
Note
Lossy strategies let you mitigate the problem of backpressure using constant memory, as we don't keep any buffers.
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...