Skip to content
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

Make 'didSet' main actor. #3206

Merged
merged 11 commits into from
Jul 17, 2024
Merged

Conversation

mbrandonw
Copy link
Member

@mbrandonw mbrandonw commented Jun 25, 2024

This fixes an issue brought up here: #3182 (comment)

In order for a @Shared value to subscribe to changes to an external system (e.g. file system, user defaults, etc.), one uses the subscribe endpoint and feeds data to didSet. Sending data to didSet ultimately mutates the @Shared value and triggers SwiftUI re-renders, and so that should take place on the main thread.

This enforces that contract by making the didSet argument @MainActor. It is technically a breaking change, but really it's a bug fix. This is a problem people may have in their custom persistence strategies right now, and they may want to investigate how to fix them.

@larryonoff
Copy link
Contributor

larryonoff commented Jul 14, 2024

Are there any plans to release this fix in the near future?

PS. I went thru the changes and don't see any issues.

@stephencelis stephencelis merged commit 54eb417 into main Jul 17, 2024
7 checks passed
@stephencelis stephencelis deleted the persistence-subscribe-main-actor-didset branch July 17, 2024 15:57
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