RxJava for Android Developers
Timo Tuominen
  • MEAP began June 2016
  • Publication in September 2018 (estimated)
  • ISBN 9781617293368
  • 450 pages (estimated)
  • printed in black & white

For Android developers, using threads effectively is absolutely necessary. It's also notoriously tricky and can cause some really nasty bugs if you don't get it right. RxJava simplifies threading on Android by creating an abstraction that hides the gnarly details of performing operations that should occur on different threads. RxJava is also a step into the world of reactive programming, which can improve the real-time responsiveness of your user interfaces, a key element of any successful Android app! RxJava for Android Developers teaches you how to build fast, fluid, and reactive apps for mobile with RxJava!

Table of Contents detailed table of contents

Part 1: Core Reactive Programming

1. Introduction to reactive programming

1.1. Perhaps you picked up this book because…​

1.2. Don't read this book if…​

1.3. OOP, Rx, FP and FRP

1.4. Benefits of Rx

1.5. What You Code is What You Get

1.6. The Reactive Landscape

1.7. What do you need to know before we start?

1.8. About the Book

1.9. RxJava 2 and Android

1.10. Setting up the Android Environment

1.11. Java 8 Lambdas

1.14. Project Set Up

1.15. Text input as a emitter of data

1.16. The Publish-Subscribe pattern

1.17. Text input as an Observable

1.18. Filtering Observables

1.19. Bending time

1.20. Bending time in our benefit

1.21. Debounce: The Bus Stop Operator

1.22. Putting it into Android

1.23. Coffee Break

1.24. Principles of Reactive Programming

1.25. Events and Marble Diagrams

1.26. Summary

2. Networking with observables

2.1. RxJava and Event Streams

2.2. Subscribers

2.3. RxJava 2 Observable Types

2.4. Subscribing to and Converting Different Observables

2.5. What Happens when We Make a Normal Network Request?

2.6. What Happens when we Make a Network Request with an Observable?

2.7. Network Request as an Observable

2.8. Example: An RSS Feed Aggregator

2.9. The feed structure

2.10. Getting the Data

2.11. The combineLatest Operator

2.12. The Rx Code so far

2.13. Coffee Break

2.14. Asynchronous Data Processing Chains

2.15. Putting the List in Order

2.16. The map Operator

2.17. Brief Introduction to Immutability

2.18. Error Handling

2.19. Adding More Feeds to the Client

2.20. Summary

3. Building data processing chains

3.1. Different Roles of Observables

3.2. Events versus Reactive State

3.3. Internal State of an Observable

3.4. Arrow Diagrams and Different Observable Types

3.5. Example: Credit Card Validation Form

3.6. First step: Expiration Date

3.7. Credit Card Number Type and Checksum

3.8. CVC Code Validation

3.9. Putting it all Together

3.10. Coffee Break

3.11. The Abstraction level of Reactive Programming

3.12. How RxJava works

3.13. Summary

4. Connecting the user interface with networking

4.1. Subscriptions Explained

4.2. Terminating Subscriptions

4.3. RxJava 2 Concepts and Subscription Management

4.4. Advanced Rx Chains Example: Flickr Search Client

4.5. Setting Up the Flickr Client Project

4.6. Overview of the Search Chain

4.8. Making it Click

4.9. Implementing the Reactive Chain

4.10. How switchMap Works

4.11. Coffee Break

4.12. Implementing the Reactive Chain

4.13. How switchMap Works

4.14. Getting Thumbnail Information

4.15. Step 1: Expand the List into an Observable

4.16. Step 2: Apply Operations to each Item Individually

4.17. Step 3: Collect Results

4.18. The Complete Solution

4.19. Adding Username from Another API

4.20. Summary

5. Advanced RxJava

5.1. Observables and Subjects in Detail

5.2. Example: File Browser

5.3. User Flow of the File Browser App

5.4. Getting the File Listing for a Directory

5.5. Threading Basics

5.6. Threading in Functional Programming

5.7. Changing the Thread Using the getFileListingObservable

5.8. Making the File Listing Dynamic

5.9. Making the List Click

5.10. Different Types of Subjects

5.11. Using a Subject as the FileObservable

5.12. Coffee Break

5.13. Adding Buttons for Back and Root

5.14. Expanded Graph for Back and Root

5.15. Improved Version with Cleaner Observables

5.16. The previous Button

5.17. Putting it all Together

5.18. The Detailed Graph

5.19. The Full Code so Far

5.20. Saving and Releasing the Subscriptions

5.21. A Final Note on Subjects

5.22. Summary

Part 2: Architectures in Reactive

6. Reactive View Models

6.1. The View Layer

6.2. Platform Containers

6.3. View Models

6.4. The Blueprint of a View Model

6.5. Connecting Views and View Models

6.6. The Whole Picture

6.7. View Model Life Cycle

6.8. Coffee Break

6.9. View Models and Android Life Cycles

6.10. The View Affinity of the Code

6.11. Summary

7. Reactive Architectures

7.1. Fundamentals of Reactive Architectures

7.2. Model - View - View Model

7.3. Reactive Model

7.4. Retrieving data from the Model

7.5. Coffee Break

7.6. Revising the File Browser

7.7. Constructing the Model for the File Browser

7.8. Using the Model

7.9. Rules of the Model and its Consumers

7.10. Single Source of Truth

7.11. Coffee Break

7.12. Persisting App State

7.13. BehaviorSubjecs and Stores

7.14. Simple SharedPreferences Store

7.15. Summary

8. Developing with view models

8.1. View Models and the View

8.2. Example: Tic-Tac Toe

8.3. Drawing the Game Grid

8.4. Making it Interactive

8.5. Events Versus Reactive State

8.6. Immutable Data and the Game Grid

8.7. Adding the Code for Interaction

8.8. Coffee Break

8.9. Wrapping the Logic into a View Model

8.10. Click Coordinate Processing

8.11. Changing Turns

8.12. Coffee Break

8.13. Filtering Illegal Moves

8.14. Winning Conditions

8.15. One More Thing: Restarting the Game

8.16. Summary

9. Expanding existing Rx apps

9.1. Working with Existing Reactive Code

9.2. The Game of Connect Four

9.3. Updating Grid Size and Assets

9.4. Checking for Valid Moves

9.5. Coffee Break

9.6. Saving and Loading the Game

9.7. Creating the Model

9.8. Sharing the Model

9.9. Loaded Games Activity

9.10. PersistedGameStore

9.11. Saving Games

9.12. Summary

10. Testing Reactive Code

10.1. Reactive Architectures and Testing

10.2. Test Granularity

10.3. The Pyramid of Dependencies

10.4. Unit Testing Basics

10.5. Testing Reactive Chains

10.6. TestSubscriber Class?

10.7. Synchronous or Asynchronous

10.8. Coffee Break

10.9. Writing Tests For View Models

10.10. Choosing What to Test

10.11. Testing GameViewModel Initial State

10.12. Testing Partial Observable Chains

10.13. Testing Connect Four Drop Logic

10.14. Summary

Part 3: Advanced Reactive

11. Advanced Architectures Chat Client 1

11.1. Chat Client with Web Socket

11.2. How to Transfer Messages?

11.3. Web Sockets

11.4. WebSockets as Broadcasters

11.5. Connecting to the Server

11.6. ChatMessage Structure

11.7. Sending ChatMessages

11.8. Wrapping Listeners into Observables

11.9. Coffee Break

11.10. Solution to Coffee Break

11.11. Basic UI

11.12. Showing Messages

11.13. The View Model

11.14. Accumulating ChatMessages

11.15. Putting Together Message Processing

11.16. Consuming Values from View Model

11.17. View Model Life Cycle

11.18. Making View Model Life Cycle

11.19. Summary

12. Advanced Architectures: Chat Client 2

12.1. View Models, Stores and the Model

12.2. Message Pending State

12.3. Handling State Updates

12.4. Store as an Aggregator

12.5. The Code for the Store

12.6. The Updated Activity Code

12.7. Coffee Break

12.8. Implementing Pending Messages

12.9. Replacing Pending Messages with Confirmed Ones

12.10. Updated Store Code

12.11. Pending State Handling Code

12.12. Coffee Break

12.13. The Model

12.14. The Code for the Model

12.15. Model Life Cycle

12.16. Singleton Modules

12.17. Android Tools for Production Use

12.18. Summary

13. Transitions with Rx

13.1. Transitioning Between States

13.2. How it Should Have Been

13.3. Animation Progress Using one Number

13.4. Reactive Parametrization

13.5. Example: The Fan Widget

13.6. Setting the Transformations for the Child Views

13.7. Coffee Break

13.8. Animating with RxJava and Android

13.9. Code Changes to FanView

13.10. The View Model

13.11. View Model Logic

13.12. Animating Parametrized Values in View Models

13.13. AnimateTo Operator

13.14. AnimateTo Operator on Android

13.15. Adding Dimmed Background

13.16. Summary

14. Making a maps client

14.1. Maps Example

14.2. Getting Started with Map Tiles

14.3. Making an Initial View Model

14.4. Calculating Tiles Based on Zoom Level

14.5. Using Offset to Move Tiles

14.6. Dragging the Map

14.7. The Code so Far

14.8. Viewport and Hiding Tiles

14.9. Loading Map Tiles

14.10. Adding Zoom Level Controls

14.11. Adding Support for Map Coordinates

14.12. Summary

Appendixes

Appendix A: Tutorial to Developing on Android

A.1. Developing on Android

A.2. Android Development Environment

A.3. Installing SDK Components

A.4. Downloading Example Projects

A.5. Using Git to Check Out Projects

A.6. Running the Project

A.7. Running Apps in the Virtual Device

A.8. Android Project Structure

A.9. Android Platform Components

A.10. Summary

Appendix B: Android manual

About the book

RxJava for Android Developers introduces the RxJava library and teaches you to apply reactive thinking to your Android applications.. You'll begin by getting into the Rx mindset of reactive data flows. You'll explore the central pattern of Rx for Android, the View Model, and learn to isolate view-related business logic from the view itself. As you read and work through the carefully-illustrated examples and exercises, you'll dig into managing change and adding new features to your mobile UIs. In this engaging, hands-on book, you'll work on interesting app features, like chat clients and elegant transitions. Along the way, you'll learn skills and patterns of thinking that you can apply to any Rx implementation, including RxJS.

What's inside

  • An introduction to reactive programming
  • Easier thread management
  • Transitions with RxJava
  • Developing View Models
  • Thinking asynchronously
  • Building a working chat client

About the reader

Readers should have some experience building Android applications.

About the author

Timo Tuominen has used FRP and RxJava extensively as an architect of a major Android project for Samsung while working with Futurice. As a consultant he has developed dozens of agile projects on almost all relevant platforms - and a number of dead ones - nowadays bringing FRP to wherever he can.

Manning Early Access Program (MEAP) Read chapters as they are written, get the finished eBook as soon as it’s ready, and receive the pBook long before it's in bookstores.
buy
RxJava for Android Developers (combo) added to cart
continue shopping
go to cart

MEAP combo $44.99 pBook + PDF
MEAP eBook $35.99 PDF only

FREE domestic shipping on three or more pBooks