Understanding the Basics of RxJava

In the last chapter, we briefly used things called Observables, but we didn't cover that in depth. That will be the goal of this chapter--we will go through the core basics of RxJava so that we can fully understand what it is, what are the core elements, and how they work.

Before that, let's take a step back and briefly discuss how RxJava is different from other approaches. RxJava is about reacting to results. It might be an item that originated from some source. It can also be an error. RxJava provides a framework to handle these items in a reactive way and to create complicated manipulation and handling schemes in a very easy-to-use interface. Things such as waiting for an arrival of an item before transforming it become very easy with RxJava.

To achieve all this, RxJava provides some basic primitives:

  • Observables: A source of data
  • Subscriptions: An activated handle to the Observable that receives data
  • Schedulers: A means to define where (on which Thread) the data is processed

First of all, we will cover Observables--the source of all the data and the core structure/class that we will be working with. We will explore how are they related to Disposables (Subscriptions).

Furthermore, the life cycle and hook points of an Observable will be described, so we will actually know what's happening when an item travels through an Observable and what are the different stages that we can tap into.

Finally, we will briefly introduce Flowable--a big brother of Observable that lets you handle big amounts of data with high rates of publishing.

To summarize, we will cover these aspects:

  • What is an Observable?
  • What are Disposables (formerly Subscriptions)?
  • How do items travel through the Observable?
  • What is Backpressure and how we can use it with Flowable?

Let's dive into it!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.15.154