Book Image

Learning RxJava

By : Thomas Nield
Book Image

Learning RxJava

By: Thomas Nield

Overview of this book

RxJava is a library for composing asynchronous and event-based programs using Observable sequences for the JVM, allowing developers to build robust applications in less time. Learning RxJava addresses all the fundamentals of reactive programming to help readers write reactive code, as well as teach them an effective approach to designing and implementing reactive libraries and applications. Starting with a brief introduction to reactive programming concepts, there is an overview of Observables and Observers, the core components of RxJava, and how to combine different streams of data and events together. You will also learn simpler ways to achieve concurrency and remain highly performant, with no need for synchronization. Later on, we will leverage backpressure and other strategies to cope with rapidly-producing sources to prevent bottlenecks in your application. After covering custom operators, testing, and debugging, the book dives into hands-on examples using RxJava on Android as well as Kotlin.
Table of Contents (21 chapters)
Title Page
Credits
About the Author
Acknowledgements
About the Reviewers
www.PacktPub.com
Customer Feedback
Preface

Why concurrency is necessary


In simpler times, computers had only one CPU and this marginalized the need for concurrency. Hardware manufacturers successfully found ways to make CPUs faster, and this made single-threaded programs faster. But eventually, this had a diminishing return, and manufacturers found they could increase computational power by putting multiple CPUs in a device. From desktops and laptops to servers and smartphones, most hardware nowadays sports multiple CPUs, or cores.

For developers, this is a major disruption in building software and how coding is done. Single-threaded software is easier to code and works fine on a single-core device. But a single-threaded program on a multi-core device will only use one core, leaving the others not utilized. If you want your program to scale, it needs to be coded in a way that utilizes all cores available in a processor.

However, concurrency is traditionally not easy to implement. If you have several independent processes that do not...