February 2020
Intermediate to advanced
412 pages
9h 36m
English
A more fluent way in which we can execute a blocking for each task is to use the blockingForEach() operator instead of blockingIterable(). This blocks the declaring thread and waits for each emission to be processed before allowing the thread to continue. We can streamline our earlier example, where we iterated over each emitted value and ensured that its length was five and specify the assertion as a lambda expression in the forEach() operator instead as follows:
import io.reactivex.rxjava3.core.Observable;import org.junit.Test;import static org.junit.Assert.assertTrue;public class Ch10_08 { @Test public void testBlockingForEach() { Observable<String> source = Observable.just("Alpha", "Beta", "Gamma", "Delta", "Zeta")
Read now
Unlock full access