Created
December 13, 2019 01:01
-
-
Save hsharghi/516344105ce070dccb56966605557c58 to your computer and use it in GitHub Desktop.
virgool-blog-0002
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
struct PostAndComments { | |
var post: Post | |
var comments: [Comment] | |
} | |
func showPostsWithComments() -> Future<[PostAndComments]> { | |
return getPostsFromDatabase().flatMap { posts -> Future<[PostAndComments]> in | |
return posts.flatMap { post -> Future<[PostAndComments]> in | |
return post.getComments().map { comments -> [PostAndComments] in | |
return PostAndComment(post: post, comments: comments) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment