June 2017
Intermediate to advanced
400 pages
8h 44m
English
The blockingMostRecent() is similar to blockingLatest(), but it will re-consume the latest value repeatedly for every next() call from the iterator even if it was consumed already. It also requires a defaultValue argument so it has something to return if no value is emitted yet. Here, we use blockingMostRecent() against an Observable emitting every 10 milliseconds. The default value is -1, and it consumes each value repeatedly until the next value is provided:
import io.reactivex.Observable; import org.junit.Test; import java.util.concurrent.TimeUnit; public class RxTest { @Test public void testBlockingMostRecent() { Observable<Long> source = Observable.interval(10, TimeUnit.MILLISECONDS) .take(5); Iterable<Long> iterable ...Read now
Unlock full access