Skip to content

Instantly share code, notes, and snippets.

@ragdroid
Created November 15, 2016 20:55
Show Gist options
  • Save ragdroid/c57471d96f9cadbf6cf6035eac541f66 to your computer and use it in GitHub Desktop.
Save ragdroid/c57471d96f9cadbf6cf6035eac541f66 to your computer and use it in GitHub Desktop.
Hit Network first and the cache
service.startupDetails(request)
.doOnNext(new Action1<StartupDetails>() {
@Override
public void call(StartupDetails startupDetails) {
startupStore.putStartupDetails(startupDetails);
}
})
.onErrorReturn(new Function<Throwable, StartupDetails>() {
@Override
public StartupDetails apply(Throwable throwable) {
//fetching startup details failed, will return cached value"
return getStartupDetailsFromCache();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment