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?

RxAndroid

AndroidSchedulers is all that remains in RxAndroid, though some method signatures have changed.

Moved

WidgetObservable and 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.

Orphaned

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!

Removed

AppObservable and its bind methods have been completely eradicated. There were a number of problems with it:

  1. It tried to auto-unsubscribe, but it would only do so if the sequence emitted an item after the Activity or Fragment paused. As a consequence, sequences that never end might never unsubscribe.
  2. It was designed to defend against notifications after pause, but it appears that bug only occurred due to a subtle logic issue in the HandlerScheduler.
  3. 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:

  1. Use manual Subscription handling (or RxLifecycle) to unsubscribe from the sequence properly.
  2. Check whether you need to add observeOn(AndroidSchedulers.mainThread()) to the sequence.