February 2020
Intermediate to advanced
412 pages
9h 36m
English
The blockingFirst() operator will stop the calling thread and make it wait for the first value to be emitted, and then return even if the chain is operating on a different thread with observeOn() and subscribeOn(). Let's say that we want to test an Observable chain that filters a sequence of the String type 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.rxjava3.core.Observable;import org.junit.Test;import static org.junit.Assert.assertTrue;public class Ch10_04 { @Test public void testFirst() { Observable<String> source = Observable.just("Alpha", "Beta", "Gamma", "Delta", "Zeta");
Read now
Unlock full access