June 2017
Intermediate to advanced
400 pages
8h 44m
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 will block the declaring thread and wait for each emission to be processed before allowing the thread to continue. We can streamline our earlier example, where we iterated each emitted string and ensured that its length was five and specify the assertion as a lambda in the forEach() operator instead:
import io.reactivex.Observable; import org.junit.Test; import static org.junit.Assert.assertTrue; public class RxTest { @Test public void testBlockingForEach() { Observable<String> source = Observable.just("Alpha", "Beta", "Gamma", "Delta", "Zeta"); source.filter(s -> s.length() == ...Read now
Unlock full access