Created
March 1, 2016 00:00
-
-
Save fchaillou/c9f798a747b939728aca to your computer and use it in GitHub Desktop.
Alamofire Result to Antitypical Result conversion
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
| import Alamofire | |
| import Foundation | |
| import enum Result.Result | |
| extension Alamofire.Result { | |
| func toStandard() -> Result<Value, Error> { | |
| switch(self) { | |
| case Alamofire.Result.Success(let value) : return Result.Success(value) | |
| case Alamofire.Result.Failure(let error) : return Result.Failure(error) | |
| } | |
| } | |
| } | |
| extension Response { | |
| func standardResult() -> Result<Value, Error> { | |
| return self.result.toStandard() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is another approach for Result interoperability. It adds
Result.ResultTypeconformance toAlamofire.Result. Appears to work pretty well.