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

Grouping operators

To group emissions by a specified key into separate observables is a powerful operation. This can be achieved by calling the groupBy(Function<T,K> keySelector) operator, which accepts a function that maps each emission to a key. It will then return an Observable<GroupedObservable<K,T>>, which emits a special type of Observable called GroupedObservable. The GroupedObservable<K,T> class is just like any other Observable, but it has the key K value accessible as a property. It emits T type values that are mapped for that given key.

For instance, we can use the groupBy() operator to group emissions for an Observable<String> by each string's length. We will subscribe to it in a moment, but here is how we declare it:

import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.observables.GroupedObservable;

public class...
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 €18.99/month. Cancel anytime