Aggregate: ToList, Reduce, and Collect
Learn about the aggregating operators.
We'll cover the following
Aggregating
RxJava has several operators that aggregate emissions from an Observable
to provide an Observer
with an intended result. Operators that aggregate are typically stateful, since an internal state must be maintained between emissions. A few commonly used aggregation operators are .toList()
, .reduce()
, and .collect()
.
ToList
The .toList()
operator converts an Observable<T>
into an Observable<List<T>>
. This is useful if the Observer
ultimately cares about a List<T>
but the stream itself pushes objects of type T
.
Get hands-on with 1400+ tech skills courses.