Last active
February 22, 2016 05:34
-
-
Save murki/8b848026f3a61ab44d8c 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
// DiskRepository.java | |
public void saveData(Data data) { | |
// implementation | |
} | |
// DomainService.java | |
@RxLogObservable | |
public Observable<Data> getMergedData() { | |
return Observable.merge( | |
diskRepository.getData().subscribeOn(Schedulers.io()), | |
networkRepository.getData() | |
.doOnNext(new Action1<Data>() { | |
@Override | |
public void call(Data data) { | |
diskRepository.saveData(data); // <-- save to cache | |
} | |
}).subscribeOn(Schedulers.io()) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment