Last active
August 8, 2018 18:51
-
-
Save amin3536/0d8cece1aaedc230495a25b44852c4ed to your computer and use it in GitHub Desktop.
This file contains 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
public Single<User> getUserById(String userId){ | |
return db.getUserById(userId) | |
/// if there is no user in the database get data from api | |
.onErrorResumeNext(api.getUserById(userId) | |
.subscribeOn(Schedulers.io()) | |
//check your request | |
.filter(statusPojo::getStatus) | |
// save data to room | |
.switchMap(data -> { | |
//sava data to db | |
return Observable.just(data) | |
}) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment