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
12.22k stars 1.42k forks source link

MainActor Store Isolation #3277

Closed stephencelis closed 2 weeks ago

stephencelis commented 1 month ago

Stores have been required to be on the main thread for a long time, but because they predate Swift concurrency, we adopted a model that was standard at the time: pushing that responsibility on the user, and warning them when we detect access off the main thread.

This PR adopts a more modern sensibility by adding @preconcurrency @MainActor to APIs that we require to be on the main thread. We'll use @preconcurrency to avoid breaking changes, but the main advantages:

This PR should not prevent us from providing stores the ability to work on non-main actors, and should actually help us get closer to that goal.

stephencelis commented 1 month ago

Some 5.10 warnings we should consider before merging, but generally things are looking good in 6.0!