February 2020
Intermediate to advanced
412 pages
9h 36m
English
The onBackPressureBuffer() takes an existing Flowable that is assumed to not have backpressure implemented and applies BackpressureStrategy.BUFFER at that point to the downstream.
Since Flowable.interval() cannot be backpressured at the source, putting onBackPressureBuffer() after it will proxy a backpressured queue to the downstream, as demonstrated by the following code:
import io.reactivex.rxjava3.core.Flowable;import io.reactivex.rxjava3.schedulers.Schedulers;public class Ch8_13 { public static void main(String[] args) { Flowable.interval(1, TimeUnit.MILLISECONDS) .onBackpressureBuffer() .observeOn(Schedulers.io()) .subscribe(i -> { sleep(5); System.out.println(i); }); sleep(5000); }}
The output is as follows:
Read now
Unlock full access