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
About the Author
About the Reviewers

Chapter 3. Creating and Connecting Observables, Observers, and Subjects

RxJava's Observable instances are the building blocks of reactive applications, and this advantage of RxJava is beneficial. If we have a source Observable instance, we could chain logic to it and subscribe for the result. All we need is this initial Observable instance.

In the browser or in a desktop application, user input is already represented by events that we can handle and forward through Observable instances. But it would be great to turn all of our data changes or actions into Observable instances, not just user input. For example, when we read data from a file, it would be neat to look at every line read or every sequence of bytes as a message that can be emitted through an Observable instance.

We'll look in detail at how different data sources can be transformed into Observable instances; it doesn't matter if they are external (files or user input) or internal (collections or scalars). What's more, we'll learn...