Skip to content

Instantly share code, notes, and snippets.

@GregoryMaks
Created August 13, 2017 10:53
Show Gist options
  • Save GregoryMaks/a907cca1532df2583274bc5079f7be07 to your computer and use it in GitHub Desktop.
Save GregoryMaks/a907cca1532df2583274bc5079f7be07 to your computer and use it in GitHub Desktop.
func requestTopPosts(completion: @escaping (Result<RedditListingResult<RedditPostServerModel>, RedditError>) -> Void) {
let request = URLRequest(url: Constants.topPostsAbsoluteURL)
networkService.perform(request: request) {
completion(
$0.flatMap(ifSuccess: self.verifyServerResponse, ifFailure: self.networkErrorToResult)
.flatMap(ifSuccess: self.parsePostModels, ifFailure: liftError)
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment