Skip to content

Instantly share code, notes, and snippets.

@jamesrochabrun
Last active July 23, 2020 08:33
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 jamesrochabrun/613caa74f009034475c579b08c137c0d to your computer and use it in GitHub Desktop.
Save jamesrochabrun/613caa74f009034475c579b08c137c0d to your computer and use it in GitHub Desktop.
MovieClient fetches movies from Movies API.
final class MovieClient: CombineAPI {
// 1
let session: URLSession
// 2
init(configuration: URLSessionConfiguration) {
self.session = URLSession(configuration: configuration)
}
convenience init() {
self.init(configuration: .default)
}
// 3
func getFeed(_ feedKind: MovieFeed) -> AnyPublisher<MovieFeedResult, Error> {
// 4
execute(feedKind.request, decodingType: MovieFeedResult.self, retries: 2)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment