Created
June 12, 2020 09:15
-
-
Save stevencurtis/4b6408b4da7195979311a17c8575bb29 to your computer and use it in GitHub Desktop.
UserListRetrievalOperation
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 UserListRetrievalOperation<T: HTTPManagerProtocol>: NetworkOperation { | |
var dataFetched: Data? | |
var httpManager: T? | |
var error: Error? | |
var url: URL? | |
init(url: URL? = nil, httpManager: T) { | |
self.url = url | |
self.httpManager = httpManager | |
} | |
override func main() { | |
guard let url = url else {return} | |
httpManager?.get(url: url, completionBlock: { data in | |
switch data { | |
case .failure(let error): | |
self.error = error | |
self.complete(result: data) | |
case .success(let successdata): | |
self.dataFetched = successdata | |
self.complete(result: data) | |
} | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment