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

Table of Contents (15 chapters)
Learning Reactive Programming with Java 8
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Combining the Observable instances


We'll first look at the zip(Observable, Observable, <Observable>..., Func) operator, which can combine two or more Observable instances using a combining function.

The zip operator

The function passed to the zip operator has as many parameters as the number of the Observable instances passed to the zip() method. When all of these Observable instances emit at least one item, the function is called with the parameter values first emitted by each of the Observable instances. Its result will be the first emitted item by the Observable instance created via the zip() method. The second item emitted by this Observable instance will be a combination (computed using the function parameter of the zip() method) of the second items of the source Observable instances. Even if one of the source Observable instances has emitted three or more items, its second emitted item is used. The resulting Observable instance always emits the same number of items as the source...