How to upgrade to RxAndroid 1.0
A number of people have asked me recently, "What the hell happened to RxAndroid?"
The fact of the matter is, RxAndroid was getting to be a bit of a mess and thus has been majorly refactored. You can read more about it here, but essentially:
I am proposing a from-scratch, modularization of the library into re-usable and composeable modules.
That has been accomplished, but if you upgrade now you're probably wondering: where did everything go and how can I get my code compiling again?
AndroidSchedulers is all that remains in RxAndroid, though some method signatures have changed.
ViewObservable have been rolled into (and improved in) RxBinding.
LifecycleObservable has been moved to RxLifecycle. In addition, they've gone through a fairly extensive behavior refactor, so make sure to check the changelogs.
ContentObservable.fromSharedPreferencesChanges() has been moved (and improved) by rx-preferences.
The rest of
ContentObservable has yet to make the move. This could be a good project for someone looking to do some open source work!
AppObservable and its bind methods have been completely eradicated. There were a number of problems with it:
- It tried to auto-unsubscribe, but it would only do so if the sequence emitted an item after the
Fragmentpaused. As a consequence, sequences that never end might never unsubscribe.
- It was designed to defend against notifications after pause, but it appears that bug only occurred due to a subtle logic issue in the
- It automatically called
observeOn(AndroidSchedulers.mainThread()), whether you wanted it or not.
In other words: it didn't do what it claimed to do, it was overly defensive, and it had undesirable side effects.
When removing it, make sure to:
- Use manual
Subscriptionhandling (or RxLifecycle) to unsubscribe from the sequence properly.
- Check whether you need to add
observeOn(AndroidSchedulers.mainThread())to the sequence.