Skip to content

Instantly share code, notes, and snippets.

@Laimiux
Last active April 23, 2017 11:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Laimiux/457b11ca64a651e8b312fbc2eb715fdb to your computer and use it in GitHub Desktop.
Save Laimiux/457b11ca64a651e8b312fbc2eb715fdb to your computer and use it in GitHub Desktop.
class UserContent {
// requires both the user and list of published content
}
Observable<Lce<User>> getUserEventStream(String userId);
Observable<Lce<List<Content>> getContentEventStream(String userId);
Observable<Lce<UserContent>> getProfileEventStream(String id) {
return Observable.combineLatest(
getUserEventStream(id),
getContentEventStream(id),
{ user, content ->
if (user.isLoading || content.isLoading) {
return Lce.loading()
} else if (user.hasError()) {
return Lce.error(user.getError()
} else if (content.hasError()) {
return Lce.error(content)
} else {
return Lce.data(createUserContent(
user.getData(), content.getData())
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment