Created
June 14, 2017 09:27
-
-
Save satoshun/0ac17a26c90ee65289632f9f5bf3f6c4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@NonNull | |
@Override public Observable<User> getUser(int id) { | |
return localDataSource.getUser(id) | |
.onErrorResumeNext( | |
remoteDataSource.getUser(id).doOnNext(new Action1<User>() { | |
@Override public void call(User user) { | |
localDataSource.saveUser(user); | |
} | |
}) | |
) | |
.subscribeOn(Schedulers.io()) | |
.observeOn(AndroidSchedulers.mainThread()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment