@Test public void testRetryAfterError() { when(wordPressService.listCategories()) .thenReturn(Single.error(new RuntimeException())); CategoryListModel model = viewModel.initAndResume(); when(wordPressService.listCategories()) .thenReturn(categoryResponse(3)); viewModel.reloadData(); assertThat(model.getItems()).hasSize(3); }
@Override protected Disposable reloadData(ObservableBoolean loadingSetter, boolean forceFetch) { loadingSetter.set(true); return wordPressService .listCategories() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .doAfterTerminate(() -> loadingSetter.set(false)) .subscribe(model::done, throwable -> model.error()); }
CategoryListViewModel extends RxListViewModel<Void, CategoryListModel> { @Override protected Disposable reloadData(ObservableBoolean loadingSetter, boolean forceFetch) { loadingSetter.set(true); return wordPressService .listCategories() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .doAfterTerminate(() -> loadingSetter.set(false)) .subscribe(model::done, throwable -> model.error()); } }
CategoryListViewModel extends RxListViewModel<Void, CategoryListModel> { @Override protected Disposable reloadData(ObservableBoolean loadingSetter, boolean forceFetch) { loadingSetter.set(true); return wordPressService .listCategories() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .doAfterTerminate(() -> loadingSetter.set(false)) .subscribe(model::done, throwable -> model.error()); } @Inject  CategoryListViewModel(); }
CategoryListViewModel extends RxListViewModel<Void, CategoryListModel> { @Override protected Disposable reloadData(ObservableBoolean loadingSetter, boolean forceFetch) { loadingSetter.set(true); return wordPressService .listCategories() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .doAfterTerminate(() -> loadingSetter.set(false)) .subscribe(model::done, throwable -> model.error()); } @Inject  CategoryListViewModel(); void goToPosts(int position); }
CategoryListViewModel extends RxListViewModel<Void, CategoryListModel> { @Override protected Disposable reloadData(ObservableBoolean loadingSetter, boolean forceFetch) { loadingSetter.set(true); return wordPressService .listCategories() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .doAfterTerminate(() -> loadingSetter.set(false)) .subscribe(model::done, throwable -> model.error()); } @Inject  CategoryListViewModel(); void goToPosts(int position);  }