-
Notifications
You must be signed in to change notification settings - Fork 3
WIP: Adding async await API to GET, POST, PUT, PATCH, DELETE and simple request. #91
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
base: develop
Are you sure you want to change the base?
Conversation
@@ -12,8 +12,9 @@ public enum APIError: Error { | |||
} | |||
|
|||
public final class Client { | |||
public typealias RequestResult<ResponseType> = (HTTPURLResponse?, Result<ResponseType, 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.
What is the difference to RequestCompletion
? Looks like you have the same type signature for it.
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.
The RequestCompletion
is a completion function but the RequestResult
is simply a return value. I would like to keep it as is to be more explicit. Furthermore I restructured the code so these type aliases are in the correct place.
@@ -127,6 +128,29 @@ public final class Client { | |||
return nil | |||
} | |||
|
|||
@available(iOS 15.0, macOS 12.0, *) |
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.
Consider moving the Version restricted parts into an extension.
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.
Restructured the Client
.
Description
With this PR the developers are able to use async await within their apps for network requests. It adds an API for GET, POST, PUT, PATCH, DELETE and a simple request. The body and response handling is adjusted to match the one where completion blocks are being used. Furthermore the possibility to use Combine was added to be able to include async network calls within a chain. Also, which can be discussed is the fact that retrying was added to the
Task
concurrency mechanism. Maybe we also want this for the completion API or we simply remove it as it won't be used for now.The state of the MR is currently WIP as we haven't yet decided what to do with the synchronous execution. Furthermore this is just a proposal which should be discussed within this PR.
Additional Notes
The API is currently only available for iOS 13.0 and macOS 10.15 apps due to additional backward compatibility of
URLSession.dataTask
.