Summary
This chapter focused on doing background operations with RxJava and coroutines. Background operations are used for long-running tasks such as accessing data from the local database or a remote server.
You started with the basics of RxJava: observables, observers, and operators. Observables are the data sources that provide data. The observers listen to observables; when an observable emits data, observers can react accordingly. Operators allow you to modify data from an observable to the data you need before it can be passed to the observers.
Next, you learned how to make RxJava calls asynchronous with schedulers. Schedulers allow you to set the thread through which the required action will be done. The subscribeOn
function is used for setting which thread your observable will run on, and the observeOn
function allows you to set where the next operators will be executed. You then fetched data from an external API with RxJava and used RxJava operators to filter, sort...