-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
runOrScheduleOnMainActor
function
#18
Conversation
RunOrScheduleOnMainActor
functionrunOrScheduleOnMainActor
function
the previous version could in some situations fail, if the main loop ran concurrently/before the schedule function returned and the TestActor continued execution (at least that's my guess, based on the fact that in some test runs the bool would unexpectedly be true.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #18 +/- ##
==========================================
+ Coverage 90.44% 90.61% +0.18%
==========================================
Files 13 14 +1
Lines 596 607 +11
==========================================
+ Hits 539 550 +11
Misses 57 57
Continue to review full report in Codecov by Sentry.
|
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.
Looks good to me; thank you @lukaskollmer 👍
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.
Thanks for the PR @lukaskollmer! 🚀
Let's tag this quickly so that we can use it within SpeziViews and SpeziChat!
# Use SpeziFoundation `runOrScheduleOnMainActor()` ## ♻️ Current situation & Problem Currently, SpeziChat manually checks and then runs or schedules (on the `MainActor`) `onPreferenceClosure()`s changes that modify `MainActor` isolated `State` properties in the SwiftUI `View`. With StanfordSpezi/SpeziFoundation#18, this lengthy and repetitive code piece is now abstracted within SpeziFoundation. ## ⚙️ Release Notes - Use [SpeziFoundation `runOrScheduleOnMainActor()`](StanfordSpezi/SpeziFoundation#18) function ## 📚 Documentation Proper documentation changes in DocC and Markdown. ## ✅ Testing No new test cases added, as behavior stays strictly the same. ## 📝 Code of Conduct & Contributing Guidelines By submitting creating this pull request, you agree to follow our [Code of Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md): - [x] I agree to follow the [Code of Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md).
runOrScheduleOnMainActor
function♻️ Current situation & Problem
As part of dealing with the
onPreferenceChange
API changes, we ended up having to duplicate code in a bunch of places, in a way that always used the same fundamental pattern (ie, if we're on the MainActor, run a piece of code directly, otherwise schedule it onto the MainActor).This PR simply abstracts this into a new global
func runOrScheduleOnMainActor
.⚙️ Release Notes
runOrScheduleOnMainActor
function📚 Documentation
n/a; all new code is directly documented.
✅ Testing
there are new test cases for the new function
📝 Code of Conduct & Contributing Guidelines
By submitting creating this pull request, you agree to follow our Code of Conduct and Contributing Guidelines: