-
-
Save amin3536/a5b396245673683f98fbe3a6b3dd8d57 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
private Flowable<List<User>> getUser(int id){ | |
return db.getUserById(id). | |
/// if there is no user in the database get data from | |
.flatMp(userList-> | |
if(userList.size=0) | |
api.getUserById(userId) | |
.subscribeOn(Schedulers.io()) | |
//check your request | |
.filter(statusPojo::getStatus) | |
// save data to room | |
.subscribe(new DisposableObserver<User>() { | |
@Override | |
public void onNext(User user) { | |
// save data to room | |
} | |
@Override | |
public void onError(Throwable e) { | |
Timber.e(e); | |
} | |
@Override | |
public void onComplete() { | |
} | |
}); | |
return Flowable.just(data) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment