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 - Non-Final SessionDelegate #1172
Conversation
cc @taquitos, @AnthonyMDev, @jshier, @kcharwood, @kylef |
@@ -1023,6 +1023,74 @@ enum Router: URLRequestConvertible { | |||
Alamofire.request(Router.ReadUser("mattt")) // GET /users/mattt | |||
``` | |||
|
|||
### SessionDelegate | |||
|
|||
By default, an Alamofire `Manager` instance creates an internal `SessionDelegate` object to handle all the various types of delegate callbacks that are generated by the underlying `NSURLSession`. The implementations of each delegate method handle the most common use cases for these types of calls abstracting the complexity away from the top-level APIs. However, advanced users may find the need to override the default functionality for various reasons. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delegate method handles
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the singular is correct, as handle
is referring do the single method being overridden, not all of the implementations together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#lackOfCoffeeError.
carry on :)
👍 On this, though an actual example of improper |
This looks great to me. |
Okay awesome guys, thanks for all the feedback! I'll go ahead and merge this now and put together another PR with the example of improper usage. |
This PR removes the
final
keyword from theSessionManager
declaration. These changes allow advanced users to subclass theSessionDelegate
, but should only be used when absolutely necessary. A simple example of such a use case would be to use a proxy pattern to emit notifications or log messages when certain APIs are called. The override closures do not allow you to do this and still use the default implementation.I also added a section to the README detailing the different ways to use the override closures vs. subclassing. Hopefully this provides enough info to allow users to make the best decision for their use case.