Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
fix bug for onError return ObservableEmpty
Browse files Browse the repository at this point in the history
  • Loading branch information
z-chu committed May 17, 2017
1 parent d637a77 commit 3019713
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.zchu.rxcache.utils.LogUtils;

import io.reactivex.Observable;
import io.reactivex.ObservableSource;
import io.reactivex.annotations.NonNull;
import io.reactivex.functions.Consumer;
import io.reactivex.functions.Function;
Expand All @@ -20,10 +21,10 @@ abstract class BaseStrategy implements IStrategy {
<T> Observable<CacheResult<T>> loadCache(final RxCache rxCache, final String key) {
return rxCache
.<T>load(key)
.onErrorReturn(new Function<Throwable, T>() {// rxjava 2.0 is not allowed null so if load(key) return null just return Observable.empty()
.onErrorResumeNext(new Function<Throwable, ObservableSource<? extends T>>() {
@Override
public T apply(@NonNull Throwable throwable) throws Exception {
return (T)Observable.empty();
public ObservableSource<? extends T> apply(@NonNull Throwable throwable) throws Exception {
return Observable.empty();
}
})
.map(new Function<T, CacheResult<T>>() {
Expand Down

0 comments on commit 3019713

Please sign in to comment.