pointfreeco / swift-composable-architecture

A library for building applications in a consistent and understandable way, with composition, testing, and ergonomics in mind.
https://www.pointfree.co/collections/composable-architecture
MIT License
11.92k stars 1.37k forks source link

Make 'didSet' main actor. #3206

Open mbrandonw opened 2 weeks ago

mbrandonw commented 2 weeks ago

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 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 commented 2 days ago

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

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