-
-
Notifications
You must be signed in to change notification settings - Fork 69
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
feat: Add async/await wrappers #212
Conversation
Codecov Report
@@ Coverage Diff @@
## main #212 +/- ##
==========================================
- Coverage 83.83% 76.68% -7.15%
==========================================
Files 80 99 +19
Lines 7392 10351 +2959
==========================================
+ Hits 6197 7938 +1741
- Misses 1195 2413 +1218
Continue to review full report at Codecov.
|
@cbaker6 Are |
What would be the use case for using async/await with a subscription callback or with subscriptions for LiveQuery in general? |
I notice that I can't run my own async code this way. Is there an alternative approach I am missing?
|
@cbaker6 Also another question, what is the correct/best way to compare errors when using async? I used to check it like this:
i thought of something like this, but I doubt it will be good:
|
I suggest reading https://www.avanderlee.com/swift/async-await/#async-methods-call-in-a-function-that-does-not-support-concurrency and https://www.andyibanez.com/posts/understanding-async-await-in-swift/ The rest of that article discusses when and how to use async/await and it's important to note it's not the solution for everything. |
Conflicts: .github/workflows/ci.yml
Do you have an idea on how to cleanly compare You think my method is the best, or are there better options? |
Your process is fine, though you can shrink the code some and handle errors with a switch: do {
//try Stuff
} catch {
guard let parseError = error as? ParseError else {
//Do stuff for different error
return
}
// Handle ParseError.
switch parseError.code {
case .objectNotFound:
// Handle object not found
default:
// There was a different issue that we don't know how to handle
}
} You can see similar in my SDK, though it's currently not using async, https://github.com/netreconlab/ParseCareKit/blob/949393ea1e74eb01ef99c165e1966ff4490a0bae/Sources/ParseCareKit/Objects/Patient.swift#L114-L144 |
@cbaker6 Question, would it be possible to merge My SPM is set on your If this isn't an option, no problem, but I think it's worth the question. Thanks in advance! |
New Pull Request Checklist
Issue Description
Add all necessary async/await wrappers. Requires Xcode 13 beta and Swift 5.5.
Developers wanting to use async/await should point their SPM to this branch.
Related issue: #234
Approach
Add async/await using wrappers around async completion methods.
TODOs before merging
ParseObject
variants and other typesParseAuthentication
typeswait for codecov.io to support Xcode 13 codecovLetting codecov slip for now since codecov.io can't read Xcode 13xcrun llvm-cov
properly. The codecov is really at 85%, will rerun when the website can read latest Xcode.