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

Notify delegate when task finishes #46

Merged
merged 4 commits into from
Jun 23, 2016

Conversation

armstrongnate
Copy link

I will need to add full support for the data task delegate eventually but I figured I'd open up a pull request as I add things. If you have any feedback let me know.

I guess this goes along with #11.

When using a delegate it is common to get the response from the
NSURLSessionTask in `URLSession:task:didCompleteWithError:`. However,
the response is never set on a SessionDataTask object so we must
override it with the interaction response.

Unfortunately this means we have to make the `interaction` a property
of SessionDataTask which adds state but the `response` is unavailable
otherwise.
@armstrongnate armstrongnate changed the title Notify delegate when task finishes Notify task and data delegate(s) when task finishes Mar 31, 2016
@armstrongnate armstrongnate changed the title Notify task and data delegate(s) when task finishes Notify delegate when task finishes Mar 31, 2016
@@ -17,6 +17,9 @@ public class Session: NSURLSession {
private var completedInteractions = [Interaction]()
private var completionBlock: (Void -> Void)?

override public var delegate: NSURLSessionDelegate? {
return backingSession.delegate
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice. 😎

@eliperkins
Copy link
Contributor

This LGTM. 🍏

@eliperkins eliperkins merged commit e4e27e0 into venmo:master Jun 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants