What I want to achieve:
- Monitor settings for a specific change
- when a change is detected, start a new network call using the new value
- conversion result
- UI display result
I know when the change will happen, now I assume that I need to call onNext on the topic. Then this should initiate the Rx chain, and in the end I can update the interface.
mViewPeriodSubject = PublishSubject.create(); mAdapterObservable = mViewPeriodSubject .flatMap(period -> MyRetrofitAPI.getService().fetchData(period)) // this might fail .flatMap(Observable::from) .map(MyItem::modifyItem) .toList() .map(obj -> new MyAdapter(obj)); mViewPeriodSubject.onNext("week"); // this one starts the chain mViewPeriodSubject.onNext("year"); // this one does not
But in the event of a network call failure, the observed errors and the onNext () call do not result in another network call.
So my question is: how do I do this? How can I keep the Observable intact so that I can just throw another value into it? I can imagine, for example, a simple redo button that just wants to ignore the fact that an error has occurred.
source share