Grokking Reactive User Interfaces
with ReactiveX and FRP
Timo Tuominen
  • MEAP began June 2016
  • Publication in Summer 2017 (estimated)
  • ISBN 9781617293368
  • 325 pages (estimated)
  • printed in black & white

In today's world, user interfaces have to be highly dynamic, asynchronous, and reliable. To meet these demands, the programming world is undergoing a radical shift in thinking about how applications should be designed. This change is called Functional Reactive Programming (FRP), or just Reactive Programming. FRP offers you a new way to construct your application so it responds directly to change. Embracing FRP lets you spend less time tracing obscure problems and more time focusing on what your code should be doing. Changing to an FRP way of thinking can be tough, and that's where this book can help.

Grokking Reactive User Interfaces teaches you a new way of thinking about programs and data as well as how to build robust and extensible user interfaces. This well-illustrated book presents lots of concrete, real-world problems and then shows you how FRP helps you solve them. You?ll begin by looking at examples that get you into the mindset of data flows. Then this book introduces the concept of a View Model and explains how it can be used as a powerful tool to isolate and unit test any view related business logic without involving the view itself. You?ll also learn how FRP enables you to better manage change and introduce new features. The final part of this book focuses on higher-level application design concerns and strategies as you look at architectural approaches and frameworks that work well with FRP thinking.

Table of Contents detailed table of contents

Part 1: Core Reactive Programming

1. Introduction reactive programming

1.1. Perhaps you picked up this bookbecause…​

1.2. Don't read this book if…​

1.3. The benefits of FRP

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

1.6. Text input as a producer of data

1.7. The Publish-Subscribe pattern

1.8. Text input as an Observable

1.9. The Reactive Stream

1.10. Bending time

1.11. Bending time in our benefit

1.12. Debounce: The Bus Stop Operator

1.13. Putting it into Android

1.14. Coffee Break

1.15. Principles of Functional Reactive Programming

1.16. Summary

2. Networking with observables

2.1. From UI events to networking

2.2. Networking and FRP

2.3. Observables & Subscribers

2.4. What happens when we make a network request?

2.5. What happens when we make a network request with an observable?

2.6. Network request as an observable

2.7. Example: An RSS feed aggregator

2.8. The feed structure

2.9. Getting the data

2.10. The combineLatest operator

2.11. The FRP code so far

2.12. Coffee Break

2.13. Putting the list in order

2.14. The map operator

2.15. Brief introduction to immutability

2.16. Error handling

2.17. Adding more feeds

2.18. Summary

3. Building data processing chains

3.1. Asynchronous data processing chains

3.2. Example: Credit card validation form

3.3. First step: Expiration Date

3.4. Credit Card Number Type and Checksum

3.5. CVC Code Validation

3.6. Putting it all Together

3.7. The abstraction level of FRP

3.8. How RxJava works

3.9. Summary

4. Connecting the user interface networking

4.1. Subscriptions Explained

4.2. Subscription Dynamics

4.3. Terminating Subscriptions

4.3.1. The observable signals it has completed

4.3.2. The subcription object is used to cancel the subscription

4.4. Advanced Rx Chains Example: Flickr Search Client

4.4.1. Overview of the Search Journey

4.4.2. The APIs

4.6. The Data Types the Search API Returns

4.7. Search and Render

4.7.1. What we have so far

4.8. Making it Click

4.9.1. Using Subscriptions

4.9.2. Managing Subscriptions

4.9.3. The Stream Approach

4.10. Implementing the Reactive Chain

4.10.1. The data graph

4.10.2. Starting an asynchronous operation in the chain

4.11. How switchMap Works

4.12. User clicks search button, triggering a requestto the Flickr API

4.12.1. User starts a new search before the first one returns from the Flickr API

4.12.2. The network request finishes without further interruption

4.13. Coffee Break

4.13.1. Exercise in Subscription Management

4.13.2. Solutions

4.14. Getting Thumbnail Information

4.14.1. The list transform pattern

4.15. Step 1: Expand the List into an Observable

4.15.1. The flatMap operator

4.15.2. Observable.merge

4.15.3. Observable of observables with merge

4.15.4. flatMap

4.15.5. Using the flatMap to expand lists

4.15.6. How it looks in the code

4.16. Step 2: Apply Operations to each ItemIndividually

4.17. Step 3: Aggregate Results

4.17.1. The Observable.concat + .toList strategy

4.18. The Complete Solution

4.18.1. The critical code in the middle of the graph

4.18.2. All together

4.19. Adding Username from Another API

4.19.1. Expanding the processing function

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. A Final Note on Subjects

5.20. Summary

Part 2: View Models in FRP

6. Basics of View Models

6.1. Layers of Logic

6.2. View Models

6.3. Using View Models on Android

6.4. Migrating Existing Code into a VM

6.5. Creating and Consuming View Models

6.6. Views and View Models

6.7. Coffee Break

6.8. Unit Testing RxJava

6.9. Test Subscribers

6.10. Synchronous or Asynchronous

6.11. Writing tests for View Models

6.12. Summary

7. Creating our first View Model

8. Expanding existing FRP apps

9. Animations with FRP

10. Making a maps client

Part 3: FRP Architectures

11. Single point of truth: the Store

12. View Model life cycles

13. Networking and stores

14. High-level FRP architectures

15. FRP and Reactive Programming overview

What's inside

  • Learn with lots of illustrations and real-life app examples
  • Using FRP in your day-to-day programming
  • Understand a new way of seeing programs as pipelines of data
  • Tackle asynchronous programming with a sustainable approach
  • Handing increasing complexity in UIs

About the reader

Readers should have a basic understanding of mobile UI development and be familiar with traditional object-oriented programming paradigms.

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.
MEAP combo $44.99 pBook + PDF
MEAP eBook $35.99 PDF only

FREE domestic shipping on three or more pBooks