Skip to content

Conversation

@SimonNumberTwo
Copy link
Collaborator

@SimonNumberTwo SimonNumberTwo commented Jan 14, 2022

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.

@SimonNumberTwo SimonNumberTwo changed the title Adding async await API to GET, POST, PUT, PATCH, DELETE and simple request. WIP: Adding async await API to GET, POST, PUT, PATCH, DELETE and simple request. Jan 14, 2022
}

public final class Client {
public typealias RequestResult<ResponseType> = (HTTPURLResponse?, Result<ResponseType, Error>)
Copy link
Contributor

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.

Copy link
Collaborator Author

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.

return nil
}

@available(iOS 15.0, macOS 12.0, *)
Copy link
Contributor

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Restructured the Client.

@SimonNumberTwo SimonNumberTwo requested a review from mrylmz January 28, 2022 13:45
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.

3 participants