Skip to content

Commit

Permalink
Replaced Alamofire Result type with AFResult typealias to Foundation.…
Browse files Browse the repository at this point in the history
…Result
  • Loading branch information
dave-kr authored and cnoon committed Mar 29, 2019
1 parent 050f4e0 commit ce428e4
Show file tree
Hide file tree
Showing 24 changed files with 523 additions and 572 deletions.
37 changes: 19 additions & 18 deletions Alamofire.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
3107EA3820A11F9600445260 /* ResponseTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8111E5E19A9674D0040E7D1 /* ResponseTests.swift */; };
3107EA3920A11F9600445260 /* ResponseTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8111E5E19A9674D0040E7D1 /* ResponseTests.swift */; };
3107EA3A20A11F9700445260 /* ResponseTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8111E5E19A9674D0040E7D1 /* ResponseTests.swift */; };
3107EA3C20A124E900445260 /* ResultTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CA028C41B7466C500C84163 /* ResultTests.swift */; };
3107EA3D20A124EA00445260 /* ResultTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CA028C41B7466C500C84163 /* ResultTests.swift */; };
3107EA3E20A124EB00445260 /* ResultTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CA028C41B7466C500C84163 /* ResultTests.swift */; };
3107EA3C20A124E900445260 /* AFResultTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CA028C41B7466C500C84163 /* AFResultTests.swift */; };
3107EA3D20A124EA00445260 /* AFResultTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CA028C41B7466C500C84163 /* AFResultTests.swift */; };
3107EA3E20A124EB00445260 /* AFResultTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CA028C41B7466C500C84163 /* AFResultTests.swift */; };
3107EA3F20A1267C00445260 /* SessionDelegateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C9DCE771CB1BCE2003E6463 /* SessionDelegateTests.swift */; };
3107EA4020A1267C00445260 /* SessionDelegateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C9DCE771CB1BCE2003E6463 /* SessionDelegateTests.swift */; };
3107EA4120A1267D00445260 /* SessionDelegateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C9DCE771CB1BCE2003E6463 /* SessionDelegateTests.swift */; };
Expand Down Expand Up @@ -155,8 +155,8 @@
4C0CB64B220CA8D600604EDC /* RedirectHandlerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C0CB64A220CA8D600604EDC /* RedirectHandlerTests.swift */; };
4C0CB64C220CA8D600604EDC /* RedirectHandlerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C0CB64A220CA8D600604EDC /* RedirectHandlerTests.swift */; };
4C0CB64D220CA8D600604EDC /* RedirectHandlerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C0CB64A220CA8D600604EDC /* RedirectHandlerTests.swift */; };
4C0E5BF81B673D3400816CCC /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C0E5BF71B673D3400816CCC /* Result.swift */; };
4C0E5BF91B673D3400816CCC /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C0E5BF71B673D3400816CCC /* Result.swift */; };
4C0E5BF81B673D3400816CCC /* AFResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C0E5BF71B673D3400816CCC /* AFResult.swift */; };
4C0E5BF91B673D3400816CCC /* AFResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C0E5BF71B673D3400816CCC /* AFResult.swift */; };
4C1DC8541B68908E00476DE3 /* AFError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C1DC8531B68908E00476DE3 /* AFError.swift */; };
4C1DC8551B68908E00476DE3 /* AFError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C1DC8531B68908E00476DE3 /* AFError.swift */; };
4C23EB431B327C5B0090E0BC /* MultipartFormData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C23EB421B327C5B0090E0BC /* MultipartFormData.swift */; };
Expand Down Expand Up @@ -271,15 +271,15 @@
4CE2724F1AF88FB500F1D59A /* ParameterEncoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CE2724E1AF88FB500F1D59A /* ParameterEncoding.swift */; };
4CE272501AF88FB500F1D59A /* ParameterEncoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CE2724E1AF88FB500F1D59A /* ParameterEncoding.swift */; };
4CEC605A1B745C9100E684F4 /* AFError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C1DC8531B68908E00476DE3 /* AFError.swift */; };
4CEC605B1B745C9100E684F4 /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C0E5BF71B673D3400816CCC /* Result.swift */; };
4CEC605B1B745C9100E684F4 /* AFResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C0E5BF71B673D3400816CCC /* AFResult.swift */; };
4CEC605C1B745C9B00E684F4 /* Alamofire.h in Headers */ = {isa = PBXBuildFile; fileRef = F8111E3819A95C8B0040E7D1 /* Alamofire.h */; settings = {ATTRIBUTES = (Public, ); }; };
4CEE82AD1C6813CF00E9C9F0 /* NetworkReachabilityManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C3D00531C66A63000D1F709 /* NetworkReachabilityManager.swift */; };
4CF626F91BA7CB3E0011A099 /* Alamofire.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4CF626EF1BA7CB3E0011A099 /* Alamofire.framework */; };
4CF627061BA7CBE30011A099 /* Alamofire.h in Headers */ = {isa = PBXBuildFile; fileRef = F8111E3819A95C8B0040E7D1 /* Alamofire.h */; settings = {ATTRIBUTES = (Public, ); }; };
4CF627071BA7CBF60011A099 /* Alamofire.swift in Sources */ = {isa = PBXBuildFile; fileRef = F897FF4019AA800700AB5182 /* Alamofire.swift */; };
4CF627081BA7CBF60011A099 /* AFError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C1DC8531B68908E00476DE3 /* AFError.swift */; };
4CF6270A1BA7CBF60011A099 /* ParameterEncoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CE2724E1AF88FB500F1D59A /* ParameterEncoding.swift */; };
4CF6270C1BA7CBF60011A099 /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C0E5BF71B673D3400816CCC /* Result.swift */; };
4CF6270C1BA7CBF60011A099 /* AFResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C0E5BF71B673D3400816CCC /* AFResult.swift */; };
4CF6270E1BA7CBF60011A099 /* MultipartFormData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C23EB421B327C5B0090E0BC /* MultipartFormData.swift */; };
4CF6270F1BA7CBF60011A099 /* ResponseSerialization.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CDE2C451AF89FF300BABAE5 /* ResponseSerialization.swift */; };
4CF627101BA7CBF60011A099 /* ServerTrustEvaluation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C811F8C1B51856D00E0F59A /* ServerTrustEvaluation.swift */; };
Expand Down Expand Up @@ -393,7 +393,7 @@
4C0CB640220CA89400604EDC /* URLRequest+Alamofire.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "URLRequest+Alamofire.swift"; sourceTree = "<group>"; };
4C0CB645220CA8A400604EDC /* RedirectHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RedirectHandler.swift; sourceTree = "<group>"; };
4C0CB64A220CA8D600604EDC /* RedirectHandlerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RedirectHandlerTests.swift; sourceTree = "<group>"; };
4C0E5BF71B673D3400816CCC /* Result.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Result.swift; sourceTree = "<group>"; };
4C0E5BF71B673D3400816CCC /* AFResult.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AFResult.swift; sourceTree = "<group>"; };
4C1DC8531B68908E00476DE3 /* AFError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AFError.swift; sourceTree = "<group>"; };
4C23EB421B327C5B0090E0BC /* MultipartFormData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MultipartFormData.swift; sourceTree = "<group>"; };
4C256A0521EEB69000AD5D87 /* RequestInterceptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestInterceptor.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -425,7 +425,7 @@
4C9E88371F5FB3B0000BEC61 /* Alamofire 2.0 Migration Guide.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; name = "Alamofire 2.0 Migration Guide.md"; path = "Documentation/Alamofire 2.0 Migration Guide.md"; sourceTree = "<group>"; };
4C9E88381F5FB3B0000BEC61 /* Alamofire 3.0 Migration Guide.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; name = "Alamofire 3.0 Migration Guide.md"; path = "Documentation/Alamofire 3.0 Migration Guide.md"; sourceTree = "<group>"; };
4C9E88391F5FB3B0000BEC61 /* Alamofire 4.0 Migration Guide.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; name = "Alamofire 4.0 Migration Guide.md"; path = "Documentation/Alamofire 4.0 Migration Guide.md"; sourceTree = "<group>"; };
4CA028C41B7466C500C84163 /* ResultTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ResultTests.swift; sourceTree = "<group>"; };
4CA028C41B7466C500C84163 /* AFResultTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AFResultTests.swift; sourceTree = "<group>"; };
4CB928281C66BFBC00CE5F08 /* Notifications.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Notifications.swift; sourceTree = "<group>"; };
4CBD217F220B48AE008F1C59 /* RetryPolicyTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RetryPolicyTests.swift; sourceTree = "<group>"; };
4CCB20681D4549E000C64D5B /* expired.badssl.com-leaf.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = "expired.badssl.com-leaf.cer"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -541,13 +541,13 @@
4C256A4E1B09656A0065714F /* Core */ = {
isa = PBXGroup;
children = (
4CA028C41B7466C500C84163 /* AFResultTests.swift */,
F8E6024419CB46A800A3E7F1 /* AuthenticationTests.swift */,
F8111E5B19A9674D0040E7D1 /* DownloadTests.swift */,
31501E872196962A005829F2 /* ParameterEncoderTests.swift */,
F8111E5C19A9674D0040E7D1 /* ParameterEncodingTests.swift */,
F8111E5D19A9674D0040E7D1 /* RequestTests.swift */,
F8111E5E19A9674D0040E7D1 /* ResponseTests.swift */,
4CA028C41B7466C500C84163 /* ResultTests.swift */,
4C9DCE771CB1BCE2003E6463 /* SessionDelegateTests.swift */,
F8D1C6F419D52968002E74FE /* SessionTests.swift */,
F8111E5F19A9674D0040E7D1 /* UploadTests.swift */,
Expand Down Expand Up @@ -710,6 +710,7 @@
isa = PBXGroup;
children = (
4C1DC8531B68908E00476DE3 /* AFError.swift */,
4C0E5BF71B673D3400816CCC /* AFResult.swift */,
319917A9209CDCB000103A19 /* HTTPHeaders.swift */,
31727417218BAEC90039FFCC /* HTTPMethod.swift */,
4CB928281C66BFBC00CE5F08 /* Notifications.swift */,
Expand All @@ -719,7 +720,6 @@
31991790209CDA7F00103A19 /* Request.swift */,
319917A4209CDAC400103A19 /* RequestTaskMap.swift */,
31991791209CDA7F00103A19 /* Response.swift */,
4C0E5BF71B673D3400816CCC /* Result.swift */,
31991792209CDA7F00103A19 /* Session.swift */,
31991793209CDA7F00103A19 /* SessionStateProvider.swift */,
31D83FCD20D5C29300D93E47 /* URLConvertible+URLRequestConvertible.swift */,
Expand Down Expand Up @@ -1119,6 +1119,7 @@
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand Down Expand Up @@ -1315,7 +1316,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4CF6270C1BA7CBF60011A099 /* Result.swift in Sources */,
4CF6270C1BA7CBF60011A099 /* AFResult.swift in Sources */,
4CF627081BA7CBF60011A099 /* AFError.swift in Sources */,
3191B5771F5F53A6003960A8 /* Protector.swift in Sources */,
3199179A209CDA7F00103A19 /* Response.swift in Sources */,
Expand Down Expand Up @@ -1378,7 +1379,7 @@
3107EA4120A1267D00445260 /* SessionDelegateTests.swift in Sources */,
31C2B0EC20B271060089BA7C /* CacheTests.swift in Sources */,
3111CE9120A7EC27008315E2 /* NetworkReachabilityManagerTests.swift in Sources */,
3107EA3E20A124EB00445260 /* ResultTests.swift in Sources */,
3107EA3E20A124EB00445260 /* AFResultTests.swift in Sources */,
4CF627171BA7CC240011A099 /* ParameterEncodingTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -1415,7 +1416,7 @@
31991795209CDA7F00103A19 /* Request.swift in Sources */,
4CDE2C441AF89F0900BABAE5 /* Validation.swift in Sources */,
3199179D209CDA7F00103A19 /* Session.swift in Sources */,
4C0E5BF91B673D3400816CCC /* Result.swift in Sources */,
4C0E5BF91B673D3400816CCC /* AFResult.swift in Sources */,
3111CE8920A77944008315E2 /* EventMonitor.swift in Sources */,
31DADDFC224811ED0051390F /* AlamofireExtended.swift in Sources */,
);
Expand All @@ -1441,7 +1442,7 @@
E4202FD21B667AA100C997FB /* ResponseSerialization.swift in Sources */,
4CB9282C1C66BFBC00CE5F08 /* Notifications.swift in Sources */,
4C0CB644220CA89400604EDC /* URLRequest+Alamofire.swift in Sources */,
4CEC605B1B745C9100E684F4 /* Result.swift in Sources */,
4CEC605B1B745C9100E684F4 /* AFResult.swift in Sources */,
4C256A0921EEB69000AD5D87 /* RequestInterceptor.swift in Sources */,
4C43669E1D7BB93D00C38AAD /* DispatchQueue+Alamofire.swift in Sources */,
E4202FD41B667AA100C997FB /* Alamofire.swift in Sources */,
Expand Down Expand Up @@ -1491,7 +1492,7 @@
31991794209CDA7F00103A19 /* Request.swift in Sources */,
4CB928291C66BFBC00CE5F08 /* Notifications.swift in Sources */,
3199179C209CDA7F00103A19 /* Session.swift in Sources */,
4C0E5BF81B673D3400816CCC /* Result.swift in Sources */,
4C0E5BF81B673D3400816CCC /* AFResult.swift in Sources */,
3111CE8820A77843008315E2 /* EventMonitor.swift in Sources */,
31DADDFB224811ED0051390F /* AlamofireExtended.swift in Sources */,
);
Expand Down Expand Up @@ -1526,7 +1527,7 @@
3107EA3F20A1267C00445260 /* SessionDelegateTests.swift in Sources */,
31C2B0EA20B271040089BA7C /* CacheTests.swift in Sources */,
3111CE8F20A7EC26008315E2 /* NetworkReachabilityManagerTests.swift in Sources */,
3107EA3C20A124E900445260 /* ResultTests.swift in Sources */,
3107EA3C20A124E900445260 /* AFResultTests.swift in Sources */,
F8111E6119A9674D0040E7D1 /* ParameterEncodingTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -1560,7 +1561,7 @@
3107EA4020A1267C00445260 /* SessionDelegateTests.swift in Sources */,
31C2B0EB20B271050089BA7C /* CacheTests.swift in Sources */,
3111CE9020A7EC27008315E2 /* NetworkReachabilityManagerTests.swift in Sources */,
3107EA3D20A124EA00445260 /* ResultTests.swift in Sources */,
3107EA3D20A124EA00445260 /* AFResultTests.swift in Sources */,
4C256A541B096C770065714F /* BaseTestCase.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
8 changes: 4 additions & 4 deletions Documentation/Usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ Alamofire.request("https://httpbin.org/get").response { response in
}
```

> We strongly encourage you to leverage the other response serializers taking advantage of `Response` and `Result` types.
> We strongly encourage you to leverage the other response serializers taking advantage of `Response` and `AFResult` types.
#### Response Data Handler

The `responseData` handler uses the `responseDataSerializer` (the object that serializes the server data into some other type) to extract the `Data` returned by the server. If no errors occur and `Data` is returned, the response `Result` will be a `.success` and the `value` will be of type `Data`.
The `responseData` handler uses the `responseDataSerializer` (the object that serializes the server data into some other type) to extract the `Data` returned by the server. If no errors occur and `Data` is returned, the response `AFResult` will be a `.success` and the `value` will be of type `Data`.

```swift
Alamofire.request("https://httpbin.org/get").responseData { response in
Expand All @@ -105,7 +105,7 @@ Alamofire.request("https://httpbin.org/get").responseData { response in

#### Response String Handler

The `responseString` handler uses the `responseStringSerializer` to convert the `Data` returned by the server into a `String` with the specified encoding. If no errors occur and the server data is successfully serialized into a `String`, the response `Result` will be a `.success` and the `value` will be of type `String`.
The `responseString` handler uses the `responseStringSerializer` to convert the `Data` returned by the server into a `String` with the specified encoding. If no errors occur and the server data is successfully serialized into a `String`, the response `AFResult` will be a `.success` and the `value` will be of type `String`.

```swift
Alamofire.request("https://httpbin.org/get").responseString { response in
Expand All @@ -118,7 +118,7 @@ Alamofire.request("https://httpbin.org/get").responseString { response in
#### Response JSON Handler

The `responseJSON` handler uses the `responseJSONSerializer` to convert the `Data` returned by the server into an `Any` type using the specified `JSONSerialization.ReadingOptions`. If no errors occur and the server data is successfully serialized into a JSON object, the response `Result` will be a `.success` and the `value` will be of type `Any`.
The `responseJSON` handler uses the `responseJSONSerializer` to convert the `Data` returned by the server into an `Any` type using the specified `JSONSerialization.ReadingOptions`. If no errors occur and the server data is successfully serialized into a JSON object, the response `AFResult` will be a `.success` and the `value` will be of type `Any`.

```swift
Alamofire.request("https://httpbin.org/get").responseJSON { response in
Expand Down
2 changes: 1 addition & 1 deletion Example/Source/DetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class DetailViewController: UITableViewController {

let start = CACurrentMediaTime()

let requestComplete: (HTTPURLResponse?, Result<String>) -> Void = { response, result in
let requestComplete: (HTTPURLResponse?, AFResult<String>) -> Void = { response, result in
let end = CACurrentMediaTime()
self.elapsedTime = end - start

Expand Down
Loading

0 comments on commit ce428e4

Please sign in to comment.