Last active
April 23, 2017 11:02
-
-
Save Laimiux/457b11ca64a651e8b312fbc2eb715fdb 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
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