private void subscribeToChanges() { RxSharedPreferences prefs = RxSharedPreferences.create(PreferenceManager.getDefaultSharedPreferences(mAppContext)); Preference<Integer> lastPage = prefs.getInteger(Constants.PREF_LAST_PAGE); Observable.merge( mBookmarkModel.tagsObservable(), mBookmarkModel.bookmarksObservable(), lastPage.asObservable()) .observeOn(AndroidSchedulers.mainThread()) .subscribe( new Action1<Object>() { @Override public void call(Object o) { if (mFragment != null) { requestData(false); } else { mCachedData = null; } } }); }
@Provides @Singleton RxSharedPreferences provideRxSharedPreferences(SharedPreferences prefs) { return RxSharedPreferences.create(prefs); }