June 2017
Intermediate to advanced
400 pages
8h 44m
English
The blockingFirst() operator will stop the calling thread and make it wait for the first value to be emitted and returned (even if the chain is operating on a different thread with observeOn() and subscribeOn()). Say we want to test an Observable chain that filters a sequence of string emissions for only ones that have a length of four. If we want to assert that the first emission to make it through this operation is Beta, we can test for it like this:
import io.reactivex.Observable; import org.junit.Test; import static org.junit.Assert.assertTrue; public class RxTest { @Test public void testFirst() { Observable<String> source = Observable.just("Alpha", "Beta", "Gamma", "Delta", "Zeta"); String firstWithLengthFour = source.filter(s ...Read now
Unlock full access