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.
This fixes an issue brought up here: https://github.com/pointfreeco/swift-composable-architecture/discussions/3182#discussioncomment-9841265
In order for a
@Shared
value to subscribe to changes to an external system (e.g. file system, user defaults, etc.), one uses thesubscribe
endpoint and feeds data todidSet
. Sending data todidSet
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.