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
Added method to expose DataResponse - RxAlamofire.request(...).responseJSON()
.
#79
Conversation
RxAlamofire.request(...).responseJSON()
.RxAlamofire.request(...).responseJSON()
.
ca582df
to
cb42ae0
Compare
let request = self.base | ||
|
||
request.responseJSON { response in | ||
if let error = response.result.error { |
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 wonder if we should send onError
in this case as it's part of the response?
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 also contemplated with that. But if we skip the error part and let the request push the error, you would end up with both an error and a next event (next sent first along with an error). I had it set up this way but wasn't sure if it makes sense, I'm down changing back if it makes more sense but I'm worried on the underlying possible confusion.
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.
So what's our final opinion on this one? We ca go either way @sergdort
} | ||
} | ||
|
||
return Disposables.create { |
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.
not sure of it's nicer but you can also do
return Disposables.create(request.cancel)
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.
Uhm yeah sure I'll add that! I usually prefer doing the closure for readability but for a one liner that's nicer for sure. Thanks !
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.
Actually this would have to be
Disposables.create(with: request.cancel)
Which really isn't as neat. I think I'll leave this with a regular closure as its a bit easier on the eye. @sergdort
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.
👍
Could anyone help with pushing this through or giving a review? It's been sitting here for 20+ days. @RxSwiftCommunity/contributors |
Thanks for the poke, the PR makes sense to me but I admit I haven't used the library extensively, so another set of eyes couldn't hurt. If in doubt, merge and we can figure out the problems later 👍 Thanks again! |
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.
Great!
} | ||
} | ||
|
||
return Disposables.create { |
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.
👍
This PR aims to resolve issue #76
This PR allows using the following syntax to access the underlying
DataResponse
object of a request: