Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Events
Videos
Audiobooks
Packt Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Learning RxJava
Learning RxJava

Learning RxJava: Build concurrent applications using reactive programming with the latest features of RxJava 3 , Second Edition

Arrow left icon
Profile Icon Nick Samoylov Profile Icon Thomas Nield
Arrow right icon
$40.99
Full star icon Full star icon Full star icon Full star icon Half star icon 4.8 (4 Ratings)
Paperback Feb 2020 412 pages 2nd Edition
eBook
$25.19 $27.99
Paperback
$40.99
Arrow left icon
Profile Icon Nick Samoylov Profile Icon Thomas Nield
Arrow right icon
$40.99
Full star icon Full star icon Full star icon Full star icon Half star icon 4.8 (4 Ratings)
Paperback Feb 2020 412 pages 2nd Edition
eBook
$25.19 $27.99
Paperback
$40.99
eBook
$25.19 $27.99
Paperback
$40.99

What do you get with Print?

Product feature icon Instant access to your digital copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Redeem a companion digital copy on all Print orders
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

Learning RxJava

Thinking Reactively

We assume that you are fairly comfortable with Java and know how to use classes, interfaces, methods, properties, variables, static/non-static scopes, and collections. If you are not familiar with concurrency or multithreading, that is okay. RxJava makes these advanced topics much more accessible.

Have your favorite Java development environment ready, be it IntelliJ IDEA, Eclipse, NetBeans, or any other environment of your choosing. We will be using IntelliJ IDEA, although it should not matter or have an impact on the examples in this book. We recommend that you have a project building framework such as Gradle or Maven, which we will explain how to use shortly.

In this chapter, before diving deeper into RxJava, we will cover some core topics:

  • A brief history of Reactive Extensions and RxJava
  • Thinking reactively
  • Leveraging RxJava
  • Setting up your first RxJava project
  • Building your first reactive applications
  • The differences between RxJava 1.x, 2.x, and 3.0

A brief history of ReactiveX and RxJava

As developers, we tend to think in counterintuitive ways. Modeling our world with code has never been short of challenges. It was not long ago that object-oriented programming was seen as the silver bullet to solve this problem. Making blueprints of what we interact with in real life was a revolutionary idea, and this core concept of classes and objects still impacts how we code today. However, business and user demands continued to grow in complexity. As 2010 approached, it became clear that object-oriented programming solved only part of the problem.

Classes and objects do a great job of representing an entity with properties and methods, but they become messy when they need to interact with each other in increasingly complex and often unplanned ways. Decoupling patterns and paradigms emerged, but this yielded an unwanted side effect of growing amounts of boilerplate code. In response to these problems, functional programming began to make a comeback, not to replace object-oriented programming, but rather to complement it and address the challenges.

Reactive programming, a functional event-driven programming approach, began to receive special attention. A couple of reactive frameworks emerged, including Akka and Sodium. But at Microsoft, a computer scientist named Erik Meijer created a reactive programming framework for .NET called Reactive Extensions. In a matter of years, Reactive Extensions (also known as ReactiveX or Rx) was ported to several languages and platforms, including JavaScript, Python, C++, Swift, and Java, of course. Soon, ReactiveX became a cross-language standard of reactive programming.

RxJava, the ReactiveX port for Java, was created in large part by Ben Christensen from Netflix and David Karnok. RxJava 1.0 was released in November 2014, followed by RxJava 2.0 in November 2016. RxJava is the backbone for other ReactiveX JVM ports, such as RxScala, RxKotlin, and RxGroovy. It has become a core technology for Android development and has also found its way into Java backend development.

Many RxJava-supporting libraries, such as RxAndroid (https://github.com/ReactiveX/RxAndroid), RxJava-JDBC (https://github.com/davidmoten/rxjava-jdbc), RxNetty (https://github.com/ReactiveX/RxNetty), and RxJavaFX (https://github.com/ReactiveX/RxJavaFX) adapted several Java frameworks to become reactive and work with RxJava out of the box. This all shows that RxJava is more than a library. It is part of a greater ReactiveX ecosystem that represents an entire approach to programming. The fundamental idea behind ReactiveX is that events are data and data are events. This is a powerful concept that we will explore later in this chapter, but first, let's step back and look at the world through the reactive lens.

Thinking reactively

Suspend everything you know about Java (and programming in general) for a moment, and let's make some observations about our world. These may sound like obvious statements, but as developers, we can easily overlook them. Try to become aware of the fact that everything is in motion. Traffic, weather, people, conversations, financial transactions, and so on are constantly changing or moving through stages.

Technically, even something as stationary as a rock is in motion, as its spatial location changes constantly due to the earth's rotation and orbiting through space. When you consider the possibility that everything can be modeled as being in motion, you may find it a bit overwhelming as a developer.

Another observation to note is that these different events are happening concurrently. Multiple activities are happening at the same time. Sometimes, they act independently, but at other times, they can converge and interact. For instance, a car can drive with no impact on a person jogging. They are two separate streams of events. However, they may converge at some point and the car will stop when it encounters the jogger.

If this is how our world works, why do we not model our code this way? Why do we not model code as multiple concurrent streams of events or data? It is not uncommon for developers to spend more time managing the states of objects and doing this in an imperative and sequential manner. You may structure your code to execute two independent processes, Process 1 and Process 2, and then Process 3, which depends on Process 1 and Process 2. Why not kick off Process 1 and Process 2 simultaneously, and then kick off Process 3 after the completion of these two processes? Of course, you can use callbacks and Java concurrency tools, but RxJava makes this much easier and safer to express.

Let's make one last observation. A book or music CD is static. A book is an unchanging sequence of words and a CD is a collection of tracks. There is nothing dynamic about them. However, when we read a book, we read one word at a time. Those words are effectively put in motion as a stream being consumed by our eyes. It is no different with a music track on a CD, where each track is put in motion as sound waves and your ears consume each track. Static items can, in fact, be put in motion too. This is an abstract but powerful idea because we create from each of these static items a series of events. When we level the playing field between data and events by treating them both the same, we unleash the power of functional programming and unlock abilities we previously might have thought impractical.

The fundamental idea behind reactive programming is that events are data and data are events. This may not seem intuitive, but it really does not take long to grasp when you consider our real-world examples. The runner and car both have properties and states, but they are also in motion. The book and CD are put in motion when they are consumed. Merging the event and data allows the code to feel organic and represent the world we are modeling.

Why should I learn RxJava?

ReactiveX and RxJava address many problems that programmers face daily, allowing them to express business logic and spend less time engineering code. Have you ever struggled with concurrency, event handling, obsolete data states, and exception recovery? What about making your code more maintainable, reusable, and evolvable so it can keep up with your business? It might be presumptuous to call reactive programming a silver bullet that eliminates these problems, but it certainly is a progressive leap toward addressing them.

There is also a growing user demand to make applications responsive in real time. Reactive programming allows you to quickly analyze and work with live data sources such as Twitter feeds or stock prices. It can also cancel and redirect work, scale with concurrency, and cope with rapidly emitting data. Composing events and data as streams that can be mixed, merged, filtered, split, and transformed opens up radically effective ways to compose and evolve the code.

In summary, reactive programming makes many hard programming tasks easy, enabling you to add value in ways you might have thought impractical earlier. If you have a process written reactively and you discover that you need to run part of it on a different thread, you can implement this change in a matter of seconds. If you find network connectivity issues crashing your application intermittently, you can gracefully use reactive recovery strategies that wait and try again. If you need to inject another operation in the middle of your process, it is as simple as inserting a new operator.

Reactive programming models data/event processing as a modular chain of links that can be added or removed quickly. Such a chain is also called a processing chain or processing pipeline. In essence, RxJava allows applications to be tactical and evolvable while maintaining stability in production.

What will you learn in this book?

As stated earlier, RxJava is the ReactiveX port for Java. In this book, we will focus primarily on RxJava 3.0, but we will highlight the significant differences between RxJava 1.x, 2.x, and 3.0 where they exist. We will place a priority on learning to think reactively and leverage the practical features of RxJava. Starting with a high-level understanding, we will gradually move deeper into how RxJava works. Along the way, you will learn about reactive patterns and tricks to solve common problems that programmers encounter.

We will cover core Rx concepts and the three core entities of RxJava: Observable, Observer, and Operator. You will start writing reactive programs immediately and will acquire a solid foundation to build upon throughout the rest of the book. Then, we will explore more of the nuances of RxJava and how to effectively leverage concurrency. You will also learn the different ways to deal with reactive streams that produce data/events faster than they can be consumed.

Finally, we will touch on several miscellaneous but essential topics, including custom operators, as well as how to use RxJava with testing frameworks, Android, and the Kotlin language.

Setting up

Currently, there are three co-existing versions of RxJava: 1.x, 2.x, and 3.0. We will go through some of the major differences later in the section entitled RxJava 1.x, 2.x, 3.0 – which one do I use? and discuss which version you should use.

RxJava 3.0 is a fairly lightweight library and comes in at fewer than 4 megabytes (MBs) in size. This makes it practical for Android and other projects that require a low dependency overhead. RxJava 3.0 has only one dependency, called Reactive Streams ( http://www.reactive-streams.org/), which is a core library (made by the creators of RxJava) that sets a standard for asynchronous stream implementations, one of which is RxJava 3.0.

RxJava 2x is even smaller—closer to 2 MB—and has only one dependency on Reactive Streams too.

It may be used in other libraries beyond RxJava and is a critical effort in the standardization of reactive programming on the Java platform. Note that RxJava 1.x does not have any dependencies, including Reactive Streams, which was realized after 1.0.

If you are starting a project from scratch, try to use RxJava 3.0. This is the version we will cover in this book, but we will point out significant differences between versions 1.x and 2.x. While RxJava 1.x and 2.x will be supported for a good while due to the countless projects using it, innovation will likely only continue onward in RxJava 3.0. RxJava 1.x reached end-of-life on March 31, 2018, and RxJava 2.x will only be maintained by fixing bugs until February 28, 2021.

All RxJava versions can run on Java 1.6+. In this book, we will use Java 8, and it is recommended that you use a minimum of Java 8 so that you can use lambdas out of the box. For Android, there are ways to leverage lambdas in earlier Java versions that will be addressed later. But due to the fact that Android Nougat uses Java 8 and Java 8 has been out since 2014, we hope that you will not have to do any workarounds to leverage lambdas.

Navigating the central repository

To bring in RxJava as a dependency, you have a number of options. The best place to start is to go to the Maven central repository, called The Central Repository (http://search.maven.org) and search for rxjava. You should see RxJava 3.0, 2.x, and 1.x as separate repositories at the top of the search results, as shown in the following screenshot:

You can also use classic search, if you're already used to its look and feel, and get the same results as shown in the following screenshot:

At the time of writing, RxJava 3.0.0 is the latest version of RxJava 3.x, RxJava 2.2.17 is the latest version of RxJava 2.x, and RxJava 1.3.8 is the latest version of RxJava 1.x. You can download the latest JAR file by clicking the link on the far right under the Download column and then configuring your project using the downloaded JAR file.

Alternatively, you can use Gradle or Maven to automatically import these libraries into your project. This way, you can easily share and store your project (through Git or other version control systems) without having to download and configure RxJava manually each time. To view the latest configurations for Maven, Gradle, and several other build automation systems, click on the Latest Version link and copy the dependency description provided into the pom.xml file (for Maven) or build.gradle file (for Gradle) of your project.

In the next two subsections, we will walk you through how to do it.

Using Gradle

There are several automated build systems available, but the two most popular ones are Gradle and Maven. Gradle is somewhat of a successor to Maven and used mostly for Android development. If you are not familiar with Gradle and would like to learn how to use it, check out the Gradle Getting Started guide (https://gradle.org/getting-started-gradle-java/).

There are also several books that cover Gradle in varying degrees of depth that you can find at https://gradle.org/books/. The following is the fragment of the above screenshot that contains Maven and Gradle configurations:

In your build.gradle script, ensure that you have declared mavenCentral() as one of your repositories. Type in or paste this dependency line, compile 'io.reactivex.rxjava2:rxjava:x.y.z', where x.y.z is the version number you want to use, as shown in the following code snippet:

apply plugin: 'java'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile 'io.reactivex.rxjava2:rxjava:x.y.z'
}

Build your Gradle project and you should be good to go! You will then have RxJava and its types available for use in your project.

Using Maven

You also have the option to use Maven, and you can view the appropriate configuration in The Central Repository by selecting the Apache Maven configuration information, as shown in the following screenshot:

You can then copy and paste the <dependency> block containing the RxJava configuration and paste it inside a <dependencies> block in your pom.xml file. Rebuild your project, and you should now have RxJava set up as a dependency. The x.y.z version number corresponds to the desired RxJava version that you want to use:

<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.nield</groupId>
<artifactId>mavenrxtest</artifactId>
<version>1.0</version>
<dependencies>
<dependency>
<groupId>io.reactivex.rxjava2</groupId>
<artifactId>rxjava</artifactId>
<version>x.y.z</version>
</dependency>
</dependencies>
</project>

A brief exposure to RxJava

Before we dive deep into the reactive world of RxJava, here is a quick immersion to get your feet wet first. In ReactiveX, the core type you will work with is the Observable class. We will be learning more about the Observable class throughout the rest of this book. But essentially, an Observable pushes things. A given Observable<T> pushes things of type T through a series of operators until it arrives at an Observer object that consumes the items.

For instance, create a new Ch1_1.java file in your project and put in the following code:

import io.reactivex.rxjava3.core.Observable;
public class Ch1_1 {
public static void main(String[] args) {
Observable<String> myStrings =
Observable.just("Alpha", "Beta", "Gamma");
}
}

In our main() method, we have an Observable<String> that will push three string objects. An Observable can push data or events from virtually any source, whether it is a database query or live Twitter feeds. In this case, we are quickly creating an Observable using Observable.just(), which will emit a fixed set of items.

In RxJava 1.x, the types are contained in the rx package. In RxJava 2.x, most types you will use are contained in the io.reactivex package. In RxJava 3.0, most types you will use are contained in the io.reactivex.rxjava3 package.

However, running this main() method is not going to do anything other than declare Observable<String>. To make this Observable actually push (or emit) these three strings, we need an Observer object to subscribe to it and receive the items. We can quickly create and connect an Observer object by passing a lambda expression that specifies what to do with each value it receives:

import io.reactivex.rxjava3.core.Observable;
public class Ch1_1 {
public static void main(String[] args) {
Observable<String> myStrings =
Observable.just("Alpha", "Beta", "Gamma");
myStrings.subscribe(s -> System.out.println(s));
}
}

When we run this code, we should get the following output:

Alpha 
Beta
Gamma

What happened here is that our Observable<String> pushed each string object one at a time to our Observer object, which we shorthanded using the s -> System.out.println(s) lambda expression. We passed each string through the (arbitrarily named) s parameter and instructed it to print each one. Lambda expressions are essentially mini-functions that allow us to quickly pass instructions on what action to take with each incoming item. Everything to the left of the arrow (->) are arguments (which, in this case, is a string we named s), and everything to the right is the action (which is System.out.println(s)).

If you are unfamiliar with lambda expressions, turn to Appendix A, Introducing Lambda Expressions, to learn more about how they work. If you want to invest extra time in understanding lambda expressions, I highly recommend that you read at least the first few chapters of Java 8 Lambdas (O'Reilly) (http://shop.oreilly.com/product/0636920030713.do), by Richard Warburton. Lambda expressions are a critical topic in modern programming and have become especially relevant to Java developers since their adoption in Java 8. We will be using lambdas constantly in this book, so definitely take some time to get comfortable with them.

We can also use several operators in the pipeline between Observable and Observer to transform each pushed item or manipulate it in some way. Each such operator applies the transformation and returns a new Observable that emits the transformed item. For example, we can use map() to turn each string emission into its length(), and each length integer will then be pushed to Observer, as shown in the following code snippet:

import io.reactivex.rxjava3.core.Observable;
public class Ch1_2 {
public static void main(String[] args) {
Observable<String> myStrings =
Observable.just("Alpha", "Beta", "Gamma");
myStrings.map(s -> s.length())
.subscribe(s -> System.out.println(s));
}
}

When we run this code, we should get the following output:

5
4
5

If you have used Java 8 streams or Kotlin sequences, you might be wondering how Observable is any different. The key difference is that Observable pushes the items, while the streams and sequences pull the items. This may seem subtle, but the impact of a push-based iteration is far more powerful than a pull-based one. As we saw earlier, you can push not only data but also events. For instance, Observable.interval() will push a consecutive Long at each specified time interval, as shown in the following code snippet. This Long emission is not only data but also an event! Let's take a look:

import io.reactivex.rxjava3.core.Observable;
import java.util.concurrent.TimeUnit;
public class Ch1_3 {
public static void main(String[] args) {
Observable<Long> secondIntervals =
Observable.interval(1, TimeUnit.SECONDS);
secondIntervals.subscribe(s -> System.out.println(s));
/* Hold main thread for 5 seconds
so Observable above has chance to fire */
sleep(5000);
}
public static void sleep(long millis) {
try {
Thread.sleep(millis);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}

When we run this code, we should get the following output:

0 
1
2
3
4

Notice that a consecutive emission fires every second. This application runs for about 5 seconds before it quits, and you likely see emissions 0 to 4 fired, each separated by a just a second-long gap. This simple idea that data is a series of events over time unlocks new possibilities in programming.

As a side note, we will get more into concurrency later, but we had to create a sleep() method because this Observable fires emissions on a computation thread when the Observable is subscribed to. The main thread used to launch our application is not going to wait on this Observable since it fires on a computation thread, not the main thread. Therefore, we use sleep() to pause the main thread for 5,000 milliseconds and then allow it to reach the end of the main() method (which will cause the application to terminate). This gives Observable.interval() a chance to fire for the 5-second window before the application quits.

Throughout this book, we will uncover many mysteries about Observable and the powerful abstractions it takes care of for us. If you've conceptually understood what's been going on here so far, congrats! You are already becoming familiar with how reactive code works. To emphasize again, emissions are pushed one at a time, all the way to Observer. Emissions represent both data and an event, which can be emitted over time. Of course, beyond map(), there are hundreds of operators in RxJava, and we will learn about the key ones in this book. Learning which operators to use for a situation and how to combine them is the key to mastering RxJava. In the next chapter, we will cover Observable and Observer much more comprehensively. We will also demystify how events and data are being represented in Observable a bit more.

RxJava 1.x, 2.x, or 3.0 – which one do I use?

As stated earlier, you are encouraged to use RxJava 3.0 if you can. This version will continue to grow and receive new features, while RxJava 1.x has not been developed further since March 21, 2018, and 2.x will be maintained for bug fixes only until February 28, 2021. However, there are other considerations that may lead you to use RxJava 1.x or 2.x.

If you inherit a project that is already using RxJava 1.x or 2.x, you will likely continue using it until it becomes feasible to migrate to RxJava 3.0. You can also check out David Karnok's RxJava2Interop project (https://github.com/akarnokd/RxJava2Interop), which converts Rx types from RxJava 1.x to RxJava 2.x and vice versa. After you finish this book, you may consider using this library to leverage RxJava 2.x even if you have the RxJava 1.x legacy code.

Migration to RxJava 3.0 requires mostly a change of import statements only. However, a few methods were dropped between RxJava 2.x and 3.0, some methods renamed, and new methods added (refer to the details at https://github.com/ReactiveX/RxJava/wiki/What's-different-in-3.0). The compiler will guide you and, for a typical, not overly large application, migration to RxJava 3.0 should be pretty straightforward, unless, of course, your application uses very particular version-specific features. In such a case, a rewrite would be the only way to proceed.

In RxJava, there are multiple libraries that can be used to make several Java APIs reactive and plug into RxJava seamlessly. To name just a few, these libraries include RxJava-JDBC, RxAndroid, RxJava-Extras, RxNetty, and RxJavaFX. At the time of writing, only RxAndroid and RxJavaFX have been fully ported to RxJava 2.x, and many other libraries will follow. By the time you are reading this, all major RxJava extension libraries will hopefully be ported to RxJava 2.x and some to RxJava 3.0, too.

You may prefer RxJava 3.0 because it was built on much of the hindsight and wisdom gained from RxJava 1.x and 2x. It has better performance, simpler APIs, a cleaner approach to backpressure, and is a bit safer when it comes to putting together your own operators.

When to use RxJava

A common question ReactiveX newcomers ask is: What circumstances warrant a reactive approach? Do we always want to use RxJava? As someone who has been living and breathing reactive programming for a while, I have learned that there are two answers to this question.

The first answer, when you first start out, is yes! You always want to take a reactive approach. The only way to truly become a master of reactive programming is to build reactive applications from the ground up. Think of everything as Observable and always model your program in terms of data and event flows. When you do this, you will leverage everything reactive programming has to offer and see the quality of your applications go up significantly.

The second answer is that as you become experienced in RxJava, you will find cases where RxJava may not be appropriate. There will occasionally be times where a reactive approach may not be optimal, but usually, this exception applies only to a part of your code. Your entire project itself should be reactive. There may be parts that are not reactive for good reason. These exceptions only stand out to a trained Rx veteran who sees that returning List<String> is perhaps better than returning Observable<String>.

Rx greenhorns should not worry about when something should be reactive versus not reactive. Over time, they will start to see cases where the benefits of Rx are marginalized, and this is something that only comes with experience.

So for now, no compromises. Go reactive all the way!

Summary

In this chapter, you have learned how to look at the world in a reactive way. As a developer, you may have to retrain yourself from a traditional imperative mindset and develop a "reactive" view. If you have done imperative, object-oriented programming for a long time, this may not be easy to accomplish, but the return on investment will be significant as your applications will become more maintainable, scalable, and evolvable. You will also have a faster turnaround and more readable code.

We also have covered how to configure an RxJava project using Gradle or Maven, and what decisions should drive whether you should choose RxJava 3.0, 2.x, or 1.x. We also got a brief introduction to reactive code and how Observable works through push-based iteration.

By the time you finish this book, you will hopefully find reactive programming intuitive and easy to work with. We hope you find that RxJava not only makes you more productive, but also helps you take on tasks you hesitated to do earlier. So let's continue!

In the next chapter, you will learn about the Observable and how it works together with the Observer. We will discuss how to create an Observable and how to use its operators. This will create a foundation that allows us to move on to more complex topics later.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Explore a variety of tools and techniques used to solve problems in implementing concurrency and parallelization
  • Learn about core operators in RxJava that enable you to express your code logic productively
  • Apply RxJava with Kotlin to create responsive Android apps with better user experience

Description

RxJava is not just a popular library for building asynchronous and event-based applications; it also enables you to create a cleaner and more readable code base. In this book, you’ll cover the core fundamentals of reactive programming and learn how to design and implement reactive libraries and applications. Learning RxJava will help you understand how reactive programming works and guide you in writing your first example in reactive code. You’ll get to grips with the workings of Observable and Subscriber, and see how they are used in different contexts using real-world use cases. The book will also take you through multicasting and caching to help prevent redundant work with multiple Observers. You’ll then learn how to create your own RxJava operators by reusing reactive logic. As you advance, you’ll explore effective tools and libraries to test and debug RxJava code. Finally, you’ll delve into RxAndroid extensions and use Kotlin features to streamline your Android apps. By the end of this book, you'll become proficient in writing reactive code in Java and Kotlin to build concurrent applications, including Android applications.

Who is this book for?

This book is for Java developers who want to leverage reactive programming to develop more resilient and concurrent applications. If you're an RxJava user looking to get to grips with the latest features and updates in RxJava 3, this book is for you. Fundamental knowledge of core Java features and object-oriented programming will assist you in understanding the key concepts covered in this book.

What you will learn

  • Discover different ways to create Observables, Observers, and Subscribers
  • Multicast in order to push data to multiple destinations and cache and replay them
  • Express RxJava idiomatically with the help of Kotlin features such as extension functions and data classes
  • Become familiar with various operators available in RxJava to perform common transformations and tasks
  • Explore RxJava's reactive types, including Flowable, Single, Maybe, and Completable
  • Demystify Observables and how they express data and events as sequences
Estimated delivery fee Deliver to Egypt

Standard delivery 10 - 13 business days

$12.95

Premium delivery 3 - 6 business days

$34.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Feb 28, 2020
Length: 412 pages
Edition : 2nd
Language : English
ISBN-13 : 9781789950151
Category :
Languages :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Redeem a companion digital copy on all Print orders
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Egypt

Standard delivery 10 - 13 business days

$12.95

Premium delivery 3 - 6 business days

$34.95
(Includes tracking information)

Product Details

Publication date : Feb 28, 2020
Length: 412 pages
Edition : 2nd
Language : English
ISBN-13 : 9781789950151
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 149.97
The Complete Coding Interview Guide in Java
$50.99
Learning RxJava
$40.99
Java Coding Problems
$57.99
Total $ 149.97 Stars icon

Table of Contents

16 Chapters
Section 1: Foundations of Reactive Programming in Java Chevron down icon Chevron up icon
Thinking Reactively Chevron down icon Chevron up icon
Observable and Observer Chevron down icon Chevron up icon
Basic Operators Chevron down icon Chevron up icon
Section 2: Reactive Operators Chevron down icon Chevron up icon
Combining Observables Chevron down icon Chevron up icon
Multicasting, Replaying, and Caching Chevron down icon Chevron up icon
Concurrency and Parallelization Chevron down icon Chevron up icon
Switching, Throttling, Windowing, and Buffering Chevron down icon Chevron up icon
Flowable and Backpressure Chevron down icon Chevron up icon
Transformers and Custom Operators Chevron down icon Chevron up icon
Section 3: Integration of RxJava applications Chevron down icon Chevron up icon
Testing and Debugging Chevron down icon Chevron up icon
RxJava on Android Chevron down icon Chevron up icon
Using RxJava for Kotlin Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.8
(4 Ratings)
5 star 75%
4 star 25%
3 star 0%
2 star 0%
1 star 0%
Jonas Okwara Aug 05, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Although am still studying the book so far am impressed with its content and how the subject matter is treated.
Amazon Verified review Amazon
Ken Siprell Apr 10, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is a great introduction to RxJava. It is written in a clear and logical manner. The code examples are easy to comprehend and lend understanding to their topic. Unlike many Packt publications this book is free of grammar and spelling errors, making it a pleasure to read. I highly recommend it!
Amazon Verified review Amazon
Abhishek Shukla May 16, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
The book covers all the important topics at depth and touches on the peripheral topics as well.Examples and operators were well explained!
Amazon Verified review Amazon
kitasanblack May 10, 2021
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
分かりやすい英語で内容を理解しやすい。サンプルコードも省略されず記されているので、動作確認がしやすい。
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the digital copy I get with my Print order? Chevron down icon Chevron up icon

When you buy any Print edition of our Books, you can redeem (for free) the eBook edition of the Print Book you’ve purchased. This gives you instant access to your book when you make an order via PDF, EPUB or our online Reader experience.

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
Modal Close icon
Modal Close icon