Skip to content

Instantly share code, notes, and snippets.

@murki
Last active March 2, 2016 18:46
Show Gist options
  • Save murki/3528dcb43a525aaf6a83 to your computer and use it in GitHub Desktop.
Save murki/3528dcb43a525aaf6a83 to your computer and use it in GitHub Desktop.
// DomainService.java
@RxLogObservable
public Observable<Data> getData() {
return getMergedData()
.onErrorReturn(new Func1<Throwable, Data>() {
@Override
public Data call(Throwable throwable) {
Log.e(CLASSNAME, "Error while fetching data. Swallowing the exception.", throwable);
return null; // We return null since we know our filter will ignore null values.
}
})
.filter(
new Func1<Data, Boolean>() {
@Override
public Boolean call(Data data) {
return data != null;
}
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment