Created
April 23, 2017 10:56
-
-
Save Laimiux/a00b7d06ee5c3ecaacf7dfd442dfd4c9 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
final PublishRelay<String> refreshRelay = PublishRelay.create() | |
void refreshData() { | |
refreshRelay.call("refresh event") | |
} | |
Observable<Lce<Data>> getDataEventStream() { | |
return refreshRelay | |
.startWith("initial") | |
.switchMap { event -> | |
api.getData() | |
.map(data -> Lce.data(data)) | |
.startWith(Lce.loading()) | |
.onErrorReturn(e -> Lce.error(e)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment