New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature - Response Generic Type #792
Feature - Response Generic Type #792
Conversation
cc @kcharwood and @kylef |
I would suggest adding an updated README along with this to help avoid confusion. |
Absolutely @cristeahub. I'd rework all the README code samples and put together another migration guide. |
…eneric_type # Conflicts: # Source/ResponseSerialization.swift
Another advantage of this is that if another parameter is added (or removed), people won't have to change every |
@macelofabri agreed! Recently upgraded a project to Swift 2.0. Even with regular expressions updating the code for the latest version of Alamofire was a pain. |
I like this change as well. Will definitely make it easier to modify the object in the future if we need too, although it will be one more round of upgrades to every call site @tobiasoleary 🍻 |
👍 |
Quick question here. The |
It was definitely intended @cristeahub. The |
This PR creates a generic
Response
type to help simplify response serialization. Instead of returning a tuple with four different values, response serializers now return a single genericResponse
object. This makes it MUCH easier to use response serializers, and will help users avoid making mistakes such as incorrectly naming the tuple parameters.I've seen MANY cases of people swapping the
request
,response
,data
andresult
parameters in the tuple. They constantly get misused with tends to lead to a large amount of confusion. Additionally, it can cause strange compiler errors that are quite difficult to debug. This PR attempts to address these issues by replacing the tuple with a genericResult
type with a genericResponse
struct.Old Usage
New Usage
This should really help alleviate misuse and should simplify response serialization usage with the concrete struct.