Last active
March 23, 2022 17:35
-
-
Save 1gravity/0d3cfd9cad694d349b127e115ea2d1b6 to your computer and use it in GitHub Desktop.
Imperative Kotlin Example
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
when (val postData = networkDataSource.getPost(id)) { | |
is Status.Success -> { | |
val comments = async { | |
networkDataSource.getComments().filter { it.postId == postData.data.id } | |
} | |
Status.Success( | |
PostDetail( | |
postData.data.id, | |
postData.data.body, | |
comments.await().map { PostComment(it.id, it.name, it.email, it.body) } | |
) | |
) | |
} | |
is Status.Failure -> Status.Failure(postData.exception) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment