Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning RxJava

You're reading from   Learning RxJava Build concurrent applications using reactive programming with the latest features of RxJava 3

Arrow left icon
Product type Paperback
Published in Feb 2020
Publisher Packt
ISBN-13 9781789950151
Length 412 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Nick Samoylov Nick Samoylov
Author Profile Icon Nick Samoylov
Nick Samoylov
Thomas Nield Thomas Nield
Author Profile Icon Thomas Nield
Thomas Nield
Arrow right icon
View More author details
Toc

Table of Contents (22) Chapters Close

Preface 1. Section 1: Foundations of Reactive Programming in Java
2. Thinking Reactively FREE CHAPTER 3. Observable and Observer 4. Basic Operators 5. Section 2: Reactive Operators
6. Combining Observables 7. Multicasting, Replaying, and Caching 8. Concurrency and Parallelization 9. Switching, Throttling, Windowing, and Buffering 10. Flowable and Backpressure 11. Transformers and Custom Operators 12. Section 3: Integration of RxJava applications
13. Testing and Debugging 14. RxJava on Android 15. Using RxJava for Kotlin 16. Other Books You May Enjoy Appendix A: Introducing Lambda Expressions 1. Appendix B: Functional Types 2. Appendix C: Mixing Object-Oriented and Reactive Programming 3. Appendix D: Materializing and Dematerializing 4. Appendix E: Understanding Schedulers

Introducing RxJava concurrency

Concurrency in RxJava is simple to execute, but somewhat abstract to understand. By default, an Observable executes on the immediate thread, which is the thread that declared the Observer and subscribed it. In many of our earlier examples, this was the main thread that kicked off our main() method.

However, as hinted in a few other examples, not every Observable fires on the immediate thread. Remember those times we used Observable.interval(), as shown in the following code? Let's take a look:

import io.reactivex.rxjava3.core.Observable;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.TimeUnit;

public class Ch6_01 {
public static void main(String[] args) {
DateTimeFormatter f = DateTimeFormatter.ofPattern("MM:ss");
System.out.println(LocalDateTime.now().format(f))...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at R$50/month. Cancel anytime