Book Image

Learning Reactive Programming With Java 8

By : Nickolay Tzvetinov
Book Image

Learning Reactive Programming With Java 8

By: Nickolay Tzvetinov

Overview of this book

If you are a Java developer that knows how to write software and would like to learn how to apply your existing skills to reactive programming, this book is for you.
Table of Contents (10 chapters)
9
Index

The conditional operators


It is possible to make it so that one Observable instance won't begin its emissions until another emits, or so that it would emit only if another doesn't emit anything. These Observable instances are able to emit items under given conditions, and these conditions are applied to them using conditional operators. In this section, we'll take a look at some of the conditional operators provided by RxJava.

The amb operator

The amb() operator has overloads that take from two up to nine source Observable instances or an Iterable instance of the Observable instances. It emits the items of the source Observable instance that starts emitting first. It doesn't matter what this is, whether OnError, OnCompleted notification, or data. Its diagram looks like this:

This operator has an instance form too. It is called ambWith() and can be called on one Observable instance in argument with another Observable instance.

This conditional operator is good for reading from multiple sources...