June 2017
Intermediate to advanced
400 pages
8h 44m
English
One of the most interesting blocking operators is blockingIterable(). Rather than returning a single emission like our previous examples, it will provide the emissions as they become available through iterable<T>. The Iterator<T> provided by the Iterable<T> will keep blocking the iterating thread until the next emission is available, and the iteration will end when onComplete() is called. Here, we iterate through each returned string value to ensure that its length is actually 5:
import io.reactivex.Observable; import org.junit.Test; import static org.junit.Assert.assertTrue; public class RxTest { @Test public void testIterable() { Observable<String> source = Observable.just("Alpha", "Beta", "Gamma", "Delta", "Zeta"); ...Read now
Unlock full access