June 2017
Intermediate to advanced
400 pages
8h 44m
English
The most powerful variance of buffer() is accepting another Observable as a boundary argument. It does not matter what type this other Observable emits. All that matters is every time it emits something, it will use the timing of that emission as the buffer cut-off. In other words, the arbitrary occurrence of emissions of another Observable will determine when to "slice" each buffer.
For example, we can perform our previous example with 300-millisecond emissions buffered every 1-second using this technique. We can have Observable.interval() of 1 second serve as the boundary for our Observable.interval()emitting every 300 milliseconds:
import io.reactivex.Observable;import java.util.concurrent.TimeUnit;public class ...
Read now
Unlock full access