Book description
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.
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.
Quotes
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
Clear and practical, the book does an amazing job of showing the power of RxJava to build Android apps.
- Cody Sand, Sandtoken
Writing code that deals with asynchronous events properly is tricky, but this book and RxJava make it much easier.
- Burk Hufnagel, Daugherty Business Solutions
Table of contents
- Copyright
- Brief Table of Contents
- Table of Contents
- Preface
- Acknowledgments
- About this book
-
Part 1. Core reactive programming
-
Chapter 1. Introduction to reactive programming
- Perhaps you picked up this book because...
- Don’t read this book if...
- OOP, Rx, FP, and FRP
- Benefits of Rx
- What you code is what you get
- The reactive landscape
- What do you need to know before you start?
- About this book
- RxJava 2 and Android
- Setting up the Android environment
- Java 8 lambdas
- Deep dive into Rx: Live search
- Conditions for triggering search
- Project setup
- Text input as an emitter of data
- The publish-subscribe pattern
- Text input as an observable
- Filtering observables
- Bending time
- Bending time to your benefit
- Debounce: The bus stop operator
- Putting your code into Android
- Coffee break
- Principles of reactive programming
- Events and marble diagrams
- Summary
-
Chapter 2. Networking with observables
- RxJava and event streams
- Subscribers
- RxJava 2 observable types
- Subscribing to and converting different observables
- What happens when you make a normal network request?
- What happens when you make a network request with an observable?
- Network request as an observable
- Example: An RSS feed aggregator
- The feed structure
- Getting the data
- The combineLatest operator
- The Rx code so far
- Coffee break
- Asynchronous data processing chains
- Putting the list in order
- The map operator
- Brief introduction to immutability
- Error handling
- Adding more feeds to the client
- Summary
-
Chapter 3. Building data processing chains
- Different roles of observables
- Events vs. reactive state
- Internal state of an observable
- Arrow diagrams and different observable types
- Example: Credit card validation form
- First step: Expiration date
- Credit card number type and checksum
- CVC code validation
- Putting it all together
- Coffee break
- The abstraction level of reactive programming
- How RxJava works
- Summary
-
Chapter 4. Connecting the user interface with networking
- Subscriptions explained
- Terminating subscriptions
- RxJava 2 concepts and subscription management
- Advanced Rx chains example: Flickr search client
- Setting up the Flickr client project
- Overview of the search chain
- Step 1: A simple hardcoded search
- Making it click
- Coffee break
- Implementing the reactive chain
- How switchMap works
- Getting thumbnail information
- Step 1: Expand the list into an observable
- Step 2: Apply operations to each item individually
- Step 3: Collect results
- The complete solution
- Adding a username from another API
- Summary
-
Chapter 5. Advanced RxJava
- Observables and subjects in detail
- Example: File browser
- User flow of the File Browser app
- Getting the file listing for a directory
- Threading basics
- Threading in functional programming
- Changing the thread by using getFileListingObservable
- Making the file listing dynamic
- Making the list click
- Different types of subjects
- Using a subject as the FileObservable
- Coffee break
- Adding buttons for Previous and Root
- Expanded graph for Previous and Root
- Improved version with cleaner observables
- The Previous button
- Putting it all together
- The detailed graph
- The full code so far
- Saving and releasing the subscriptions
- A final note on subjects
- Summary
-
Chapter 1. Introduction to reactive programming
-
Part 2. Architectures in RxJava
- Chapter 6. Reactive view models
-
Chapter 7. Reactive architectures
- Fundamentals of reactive architectures
- Model-View-View model
- Reactive model
- Retrieving data from the model
- Coffee break
- Revising the file browser
- Constructing the model for the file browser
- Using the model
- Rules of the model and its consumers
- Single source of truth
- Coffee break
- Persisting app state
- BehaviorSubjects and stores
- Simple SharedPreferencesStore
- Summary
-
Chapter 8. Developing with view models
- View models and the view
- Example: Tic-tac-toe
- Drawing the game grid
- Making it interactive
- Events vs. reactive state
- Immutable data and the game grid
- Adding the code for interaction
- Coffee break
- Wrapping the logic into a view model
- Click coordinate processing
- Changing turns
- Coffee break
- Filtering illegal moves
- Winning conditions
- One more thing: Restarting the game
- Summary
- Chapter 9. Expanding existing Rx apps
-
Chapter 10. Testing reactive code
- Reactive architectures and testing
- Test granularity
- The pyramid of dependencies
- Unit-testing basics
- Testing reactive chains
- TestObservable class
- Synchronous or asynchronous
- Coffee break
- Writing tests for view models
- Choosing what to test
- Testing the GameViewModel initial state
- Testing partial observable chains
- Testing Connect Four drop logic
- Summary
-
Part 3. Advanced RxJava architectures
-
Chapter 11. Advanced architectures: Chat client 1
- Chat client with WebSockets
- How to transfer messages
- WebSockets
- WebSockets as broadcasters
- Connecting to the server
- ChatMessage structure
- Sending ChatMessages
- Wrapping listeners into observables
- Coffee break
- Basic UI
- Showing messages
- The view model
- Accumulating ChatMessages
- Putting together message processing
- Consuming values from the view model
- View model lifecycle
- Making the view model lifecycle
- Summary
-
Chapter 12. Advanced architectures: Chat client 2
- View models, stores, and the model
- Message pending state
- Handling state updates
- Store as an aggregator
- The code for the store
- Coffee break
- Implementing pending messages
- Replacing pending messages with confirmed ones
- Updated store code
- Pending state handling code
- Coffee break
- The model
- The code for the model
- Model lifecycle
- Singleton modules
- Android tools for production use
- Summary
-
Chapter 13. Transitions with Rx
- Transitioning between states
- How it should have been
- Animation progress using one number
- Reactive parametrization
- Example: The fan widget
- Setting the transformations for the child views
- Coffee break
- Animating with RxJava and Android
- Code changes to FanView
- The view model
- View model logic
- Animating parametrized values in view models
- animateTo operator
- animateTo operator on Android
- Adding a dimmed background
- Summary
- Chapter 14. Making a maps client
-
Chapter 11. Advanced architectures: Chat client 1
- Appendix. Tutorial for developing on Android
- Index
Product information
- Title: RxJava for Android Developers
- Author(s):
- Release date: May 2019
- Publisher(s): Manning Publications
- ISBN: 9781617293368
You might also like
book
RxJava for Android App Development
RxJava is the "new hotness" for Android development. However, there are still many developers that aren't …
book
iOS 6 Programming Cookbook
Overcome the vexing issues you’ll inevitably confront when creating apps for the iPhone, iPad, or iPod …
book
Windows® 7 Visual™ Quick Tips
Quick and easy answers for common Windows 7 questions Windows 7 is the operating system used …
book
Java I/O, 2nd Edition
All of Java's Input/Output (I/O) facilities are based on streams, which provide simple ways to read …