Last active
March 30, 2019 21:49
-
-
Save nanoxd/505f5adf2736a18e126b6892aea7bd0e to your computer and use it in GitHub Desktop.
Request+Result.swift #swift
This file contains hidden or 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
extension Request where Response: Decodable { | |
func handle( | |
response: Result<Data, Error>, | |
completion: (Result<Response, Error>) -> Void) { | |
completion(Result { | |
try JSONDecoder().decode(Response.self, from: response.get()) | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment