Composing Observables
As we explained earlier, an Observable
interface is defined in a way that allows us to chain and combine different Observables
to create complex tasks in a functional and declarative way.
Starting from our previous work, in our next example, we will make use of the RxJava
composing feature and execute a second network call that depends on the previous Observable
that will translate the text downloaded using a web service before we emit the translated text to the Subscriber
.
To execute the translation on the network on a logically separate unit, we will create a new Observable
that receives the text to translate, executes the task on the network, and emits the translated text as a String to the following Observable
:
Observable<String> ...
Get Asynchronous Android Programming - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.