Skip to content

Instantly share code, notes, and snippets.

@Laimiux
Created April 23, 2017 10:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Laimiux/a00b7d06ee5c3ecaacf7dfd442dfd4c9 to your computer and use it in GitHub Desktop.
Save Laimiux/a00b7d06ee5c3ecaacf7dfd442dfd4c9 to your computer and use it in GitHub Desktop.
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