Exploring the implications of making Store conform to ObservableObject
#3495
Replies: 1 comment 3 replies
-
|
Hi @b1ackturtle, thanks for bringing this up. I don't think there are many noticeable implications of making Overall I just think it's a big bummer that And so you could follow Apple's advice and use the I could see us adding this conformance to the library at some point, especially with some researching we've been doing into "detached" stores. But I would only want to do so with copious amounts of documentation that details we are only doing this to work around SwiftUI's deficiencies. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
What are your thoughts on having
Storeconform toObservableObject, both in terms of behavior and the implications of conforming when definingStorein the library?I am using TCA in a multi-module product, where each module represents a bounded context. I believe that making Reducers public, as seen in isowords, and allowing them to be referenced by parent modules does not properly maintain these boundaries. Therefore, I keep Reducers internal and create a Root Store for each module's Reducer.
When using TCA in this way, there are times when I need to initialize a
Storewithin aView. If I use@Stateto hold theStore, it gets reinitialized every time theViewis initialized, which may not lead to the expected behavior.One solution to this problem is to hold the
Storeusing@StateObject. To do this, theStoremust conform toObservableObject. I would like to know if there are any issues with havingStoreconform toObservableObject. Additionally, I am interested in the pros and cons of havingStoreconform toObservableObjectat the time of its definition.Beta Was this translation helpful? Give feedback.
All reactions