RxJava for Android Developers
Timo Tuominen
  • April 2019
  • ISBN 9781617293368
  • 512 pages
  • printed in black & white

A terrific introduction to a complex topic. The examples are real enough to be useful when writing your own applications without bogging you down in extraneous detail.

Mark Elston, Advantest America

RxJava for Android Developers teaches you how to build fast, fluid, and reactive mobile apps for Android with RxJava.

About the Technology

For Android developers, writing multithreaded apps can be as challenging as it is necessary. RxJava simplifies complex threading operations, maintaining proper synchronization as you switch seamlessly from thread to thread. RxJava also brings the benefits of reactive programming to your apps—that means better real-time responsiveness, the holy grail for every Android developer.

About the book

RxJava for Android Developers begins by inviting you to think about programming and data the reactive way. This engaging, hands-on essential reference introduces you to the central pattern of RxJava for Android, then explains the View Model before exploring highly sought-after app features like chat clients and elegant transitions. Finally, you’ll look at high-level design concerns and architectural approaches and frameworks that work well with Functional Reactive Programming (FRP) thinking.

Table of Contents detailed table of contents

Part 1: Core Reactive Programming

1. 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 to your benefit

1.21. Debounce: The bus stop operator

1.22. Putting your code into Android

1.23. Principles of Reactive Programming

1.24. Events and marble diagrams

2. 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 you make a normal network request?

2.6. What happens when you 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. Asynchronous data processing chains

2.14. Putting the list in order

2.15. The map operator

2.16. Brief introduction to immutability

2.17. Error handling

2.18. Adding more feeds to the client

3. 3 Building data processing chains

3.1. Different roles of observables

3.2. Events vs. 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. The abstraction level of reactive programming

3.11. How RxJava works

4. 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

5. 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. Adding buttons for Previous and Root

5.13. Expanded graph for Previous and Root

5.14. Improved version with cleaner observables

5.15. The Previous button

5.16. Putting it all together

5.17. The detailed graph

5.18. The full code so far

5.19. Saving and releasing the subscriptions

5.20. A final note on subjects

Part 2: Architectures in RxJava

6. 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 lifecycle

6.8. Coffee Break

6.9. View models and the Android lifecycles

6.10. The view affinity of the code

7. 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 SharedPreferencesStore

8. 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 vs. 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

9. 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. Saving and loading the game

9.6. Creating the model

9.7. Sharing the model

9.8. Loaded games activity

9.9. PersistedGameStore

9.10. Saving Games

9.11. Loading games

10. 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. TestObservable class

10.7. Synchronous or asynchronous

10.8. Writing tests for view models

10.9. Choosing what to test

10.10. Testing the GameViewModel initial state

10.11. Testing partial observable chains

10.12. Testing Connect Four drop logic

Part 3: Advanced RxJava architectures

11. 11 Advanced architectures: Chat client 1

11.1. Chat client with WebSockets

11.2. How to transfer messages

11.3. WebSockets

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. Basic UI

11.10. Showing messages

11.11. The view model

11.12. Accumulating ChatMessages

11.13. Putting together message processing

11.14. Consuming values from the view model

11.15. View model lifecycle

11.16. Making the view model lifecycle

12. 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. Implementing pending messages

12.7. Replacing pending messages with confirmed ones

12.8. Updated store code

12.9. Pending state handling code

12.10. Pending state handling code

12.11. The code for the model

12.12. Model lifecycle

12.13. Singleton modules

12.14. Android tools for production use

13. 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. Animating with RxJava and Android

13.8. Code changes to FanView

13.9. The view model

13.10. View model logic

13.11. Animating parametrized values in view models

13.12. animateTo operator

13.13. animateTo operator on Android

13.14. Adding a dimmed background

14. 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


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

What's inside

  • An introduction to reactive programming
  • Easier thread management
  • Improving UI responsiveness
  • Thinking asynchronously
  • Building a working chat client

About the reader

Readers should have some experience building Android applications. No experience with RxJava is needed.

About the author

Timo Tuominen has used FRP and RxJava extensively while working with Futurice as an architect of a major Android project for Samsung.

placing your order...

Don't refresh or navigate away from the page.
print book $26.99 $44.99 pBook + eBook + liveBook
Additional shipping charges may apply
RxJava for Android Developers (print book) added to cart
continue shopping
go to cart

eBook $28.79 $35.99 3 formats + liveBook
RxJava for Android Developers (eBook) added to cart
continue shopping
go to cart

Prices displayed in rupees will be charged in USD when you check out.
customers also reading

This book 1-hop 2-hops 3-hops

FREE domestic shipping on three or more pBooks