I read here that we can use some global cache in order to handle rotation.
You can prevent this by using the cache or replay Observable operators, while making sure the Observable somehow survives the Activity life-cycle (for instance, by storing it in a global cache, in a Fragment, etc.)
But how to achieve that? Somebody can point me to some example how to do it? Or maybe you know some better approach to handle configuration change?
EDIT:
For now I have found many ways, but I ended up with using RxBus realisation. Nice example of using RxBus you can find here.
Rx gives you a very granular control over which threads will be used to perform work in various points within a stream. To point the contrast here already, basic call approach used in Retrofit is only scheduling work on its worker threads and forwarding the result back into the calling thread.
The major difference between RxAndroid and RxJava is Schedulers. Schedulers are specifically available in RxAndroid not in RxJava which helps in efficient threading.
I have made a demo application (https://github.com/pmellaaho/RxApp) in order to experiment how tackle the kinds of situations in Android application. To put it short I use a singleton model from Activity to get the response from network. This makes it possible to cache responses, access the data from multiple UI components, subscribe to pending request and also to provide mock data for automated UI tests.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With