Jon_Shier
(Jon Shier)
1
I've just created a PR which adds extensions for most Alamofire protocols to enable static access to our convenience types. At its simplest it enables somewhat cleaner usage than the previous form:
Previously
AF.request("https://httpbin.org/post",
method: .post,
parameters: Value(),
encoder: JSONParameterEncoder(),
interceptor: RetryPolicy())
.response(responseSerializer: DecodableResponseSerializer<TestResponse>()) { response in
debugPrint(response)
}
Now
AF.request("https://httpbin.org/post",
method: .post,
parameters: Value(),
encoder: .json,
interceptor: .retryPolicy)
.response(responseSerializer: .decodable(of: TestResponse.self)) { response in
debugPrint(response)
}
Feel free to take the new APIs for a spin and let me know what you think. I hope to release it sometime in the next week.
1 Like
mtsrodrigues
(Mateus Rodrigues)
2
I think it would be nice to have static var as an alternative for cases when the function can be used without passing paremeters:
AF.request("https://httpbin.org/post",
method: .post,
parameters: Value(),
encoder: .json,
interceptor: .retryPolicy)
.response(responseSerializer: .decodable(of: TestResponse.self)) { response in
debugPrint(response)
}
SwiftUI does that for BorderedListStyle.
https://developer.apple.com/documentation/swiftui/liststyle/bordered
https://developer.apple.com/documentation/swiftui/liststyle/bordered(alternatesrowbackgrounds:)
Jon_Shier
(Jon Shier)
3
Good suggestion, implemented!
1 Like