Transforming Observables
Apart from the ability to widely implement the Observable-Subscribe
software pattern, the RxJava
framework allows us to transform, filter, convert, aggregate, manipulate, and work with the stream of items emitted by Observable
by using Observable
operators. These entities are able to completely transform the event stream before the events are delivered to the final Subscriber
.
RxJava
comes with a handy collection of operators that are able to transform the event's content and control the time that the event is delivered.
Let's describe the most common operators available on RxJava
:
map
: Applies a function to each item emitted and emits the result of the function as a new item.flatMap
: Applies a function to each item emitted by the sourceObservable
where the function returns anObservable
that could emit a different number of items or a different type of event.filter
: A transformation operator that uses a function that verifies if each item emitted by the...