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