February 2020
Intermediate to advanced
412 pages
9h 36m
English
The Maybe and Single interfaces do not have blockingFirst() since there can only be one element at most. Logically, for Single and Maybe, it is not exactly the first element, but rather the only element, so the equivalent operator is blockingGet().
Here, we assert that all items of length four include only Beta and Zeta, and we collect them with toList(), which yields a Single<List<String>>. We can use blockingGet() to wait for this list and assert that it contains the expected values as follows:
import io.reactivex.rxjava3.core.Observable;import org.junit.Test;import java.util.Arrays;import java.util.List;import static org.junit.Assert.assertTrue;public class Ch10_05 { @Test public void testSingle() { Observable<String> source ...
Read now
Unlock full access