June 2017
Intermediate to advanced
400 pages
8h 44m
English
The iterable from blockingLatest(), on the other hand, does not wait for the next value, but requests the last emitted value. Any values before that which were not captured are forgotten. It will not reconsume the latest value if the iterator's next() consumed it previously and will block until the next one comes:
import io.reactivex.Observable; import org.junit.Test; import java.util.concurrent.TimeUnit; public class RxTest { @Test public void testBlockingLatest() { Observable<Long> source = Observable.interval(1, TimeUnit.MICROSECONDS) .take(1000); Iterable<Long> iterable = source.blockingLatest(); for (Long i: iterable) { System.out.println(i); } } }
The output is as follows:
0495153555658...
Read now
Unlock full access