-
Notifications
You must be signed in to change notification settings - Fork 74
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
Introduce Swift-only request APIs #194
Conversation
@kmcbride One opportunity of improvement I see with the request-handler closure is to expose the HTTP response. So that the closure can for example look at the HTTP status code. I find that quite useful form time to time. For example when distinguishing between a network error and a server error. Or when deciding how to handle an error, like differentiating between a HTTP 403 and 500 status code. Also, have you considered adding a method for parsing server errors? E.g. something like: dataLoader
.validate(ServerError.self)
.request(request) { (response: Response<Album, ServerError>) in ... }
// Or
dataLoader.request(validateUsing: Validator.self, request) { (response: Response<Album, ServerError>) in ... }
// Or
dataLoader.request(validateUsing: validator, request) { (response: Response<Album, ServerError>) in ... } The handler closure would still need to handle |
@rastersize I like the idea of being able to chain a validator and I did explore it at one point, but it seemed like it would require refactoring internals beyond what could be provided by a simple wrapper. Including it as a parameter to the request method is a possibility, but would cause a bit of API bloat due to the inability to use default values in the protocol. In the interim, I've added an additional |
Sources/SPTDataLoaderSwift/SPTDataLoaderFactory+Convenience.swift
Outdated
Show resolved
Hide resolved
@kmcbride I think this looks good to merge. The only thing left, in my mind, is to fix the Codecov issue. Which I think could be fixed, or at least partially fixed, by updating the |
@rastersize The codecov file only has ignores not paths to look for code. Something is broken on their end. @kmcbride If you give me write access to your fork, I can fiddle with this locally. |
My comment was a bit confusing, I meant to add the new tests directory to the exclude list. I was hoping that would get Codecov to pick things up. If nothing else it should get rid of the warnings added to the test files. |
@rastersize @dflems I've somewhat fixed the codecov issues:
|
Codecov Report
@@ Coverage Diff @@
## master #194 +/- ##
==========================================
+ Coverage 94.03% 94.39% +0.36%
==========================================
Files 17 21 +4
Lines 1039 1106 +67
==========================================
+ Hits 977 1044 +67
Misses 62 62
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
These changes take the idea behind SPTDataLoaderBlockWrapper.m and expand upon it to provide protocol-oriented APIs that better utilize Swift language features.
Example Usage
Adding Custom Response Serializer