June 2017
Intermediate to advanced
400 pages
8h 44m
English
The blockingNext() will return an iterable and block each iterator's next() request until the next value is provided. Emissions that occur after the last fulfilled next() request and before the current next() are ignored. Here, we have a source that emits every microsecond (1/1000th of a millisecond). Note that the iterable returned from blockingNext() ignored previous values it missed:
import io.reactivex.Observable; import org.junit.Test; import java.util.concurrent.TimeUnit; public class RxTest { @Test public void testBlockingNext() { Observable<Long> source = Observable.interval(1, TimeUnit.MICROSECONDS) .take(1000); Iterable<Long> iterable = source.blockingNext(); for (Long i: iterable) { System.out.println(i); } } } ...Read now
Unlock full access