Book Image

RxJava Essentials

By : Ivan Morgillo
Book Image

RxJava Essentials

By: Ivan Morgillo

Overview of this book

<p>RxJava—Reactive Extensions for the JVM—is a library for composing asynchronous and event-based programs using Observable sequences for the Java VM, which will help you beat Android platform limitations to create astonishing Android apps.</p> <p>Starting with some quick background information on the Rx .NET library, this book quickly moves on to your first example. You will understand Observables and learn to filter, transform, or merge them in detail. Next, you will learn how to get rid of Threads, AsyncTasks, and Handlers with Schedulers to create a smooth user experience. Develop an easy, ready-to-go approach to REST API communications and enrich your skills by working with new challenging examples.</p> <p>By the end of the book, you will have explored the reactive programming world and will have created your first Android app without having to think about threading, networking, concurrency, and collection management.</p> <p>The images have been taken from&nbsp;<a href="http://reactivex.io/" target="_blank">http://reactivex.io/</a> which is licensed under a Create Commons 3.0 Attribution license (<a href="https://creativecommons.org/licenses/by/4.0/" target="_blank">https://creativecommons.org/licenses/by/4.0/</a>)</p>
Table of Contents (15 chapters)

The Observer pattern


Nowadays, the Observer pattern is one of the most common software design patterns on the scene. It's based on the concept of subject. A subject is a particular object that keeps a list of objects that want to be notified when the subject changes. These objects are called Observers and they expose a notification method that the subject invokes when its state changes.

In the previous chapter, we saw the spreadsheet example. Now we can expand the example, showing a more complex scenario. Let's think about a spreadsheet containing the accounting data. We could represent this data as a table, as a 3D-histogram, or as a pie chart. Every one of these representations will depend on the same set of data being displayed. Every one of these representations will be an Observer, depending on one single subject, maintaining all the information.

The 3D-histogram class, the pie chart class, the table class, and the class maintaining the data are perfectly decoupled: they can be used and...