-
Notifications
You must be signed in to change notification settings - Fork 121
Update OrdersRemote with async/throws network methods to parse orders response in a background thread
#15982
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
Conversation
…e handling is not on the main thread.
… handling is not on the main thread.
|
|
OrdersRemote with async/throws network methods to parse orders response in a background thread
iamgabrielma
left a comment
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.
Works great! Thanks for your work modernizing those.
I left a couple of nits, feel free to address them or not 👍
| switch result { | ||
| case .success(let orders): | ||
| self?.upsertStoredOrdersInBackground(readOnlyOrders: orders) { | ||
| Task { @MainActor in |
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.
nit: The alignment of these props seems to be off!
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.
Fixed the alignment in 8377aba.
| /// Verifies that loadAllOrders properly parses the `orders-load-all` sample response. | ||
| /// | ||
| func testLoadAllOrdersProperlyReturnsParsedOrders() throws { | ||
| func testLoadAllOrdersProperlyReturnsParsedOrders() async throws { |
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.
nit: Since we're updating the test signature we can update the test name to use snake case as well 🐍 , ideally with when/then too.
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.
Makes sense, updated in aa00e4c.
e9e1be6 to
aa00e4c
Compare

For WOOMOB-981
Just one review is required.
Description
Updates
OrdersRemote.loadAllOrdersandOrdersRemote.searchOrdersmethods to use modern async/await interface instead of completion handlers. This change improves response handling by ensuring it doesn't occur on the main thread and follows current Swift concurrency best practices. These two methods are the only ones inOrdersRemotethat fetch and parse a list of orders, which includemeta_datafield that can include any number of values resulting in a large response size.The updated methods now:
async throwsinstead of completion handlers which parse the response on the main threadAll call sites have been updated to maintain compatibility:
@MainActorfor thread safetySteps to reproduce
init(from:)Testing information
I tested on iPad A16 iOS 18.4 simulator.
RELEASE-NOTES.txtif necessary.