Skip to content
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

Merged
merged 2 commits into from Apr 12, 2016
Merged

Conversation

cnoon
Copy link
Member

@cnoon cnoon commented Apr 9, 2016

This PR removes the final keyword from the SessionManager declaration. These changes allow advanced users to subclass the SessionDelegate, 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.

@cnoon
Copy link
Member Author

cnoon commented Apr 9, 2016

@@ -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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delegate method handles

Copy link
Contributor

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#lackOfCoffeeError.
carry on :)

@jshier
Copy link
Contributor

jshier commented Apr 11, 2016

👍 On this, though an actual example of improper subdelegates usage might be a good idea, if it can be such an issue.

@taquitos
Copy link

This looks great to me.

@AnthonyMDev
Copy link
Contributor

I'm happy with this too. I agree with @jshier about adding an example of improper usage. Otherwise, great job @cnoon!

@cnoon
Copy link
Member Author

cnoon commented Apr 12, 2016

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.

@cnoon cnoon merged commit bb0d1a7 into master Apr 12, 2016
@cnoon cnoon deleted the feature/non_final_session_delegate branch April 12, 2016 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants