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.
-
What are your thoughts on having
Store
conform toObservableObject
, both in terms of behavior and the implications of conforming when definingStore
in 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
Store
within aView
. If I use@State
to hold theStore
, it gets reinitialized every time theView
is initialized, which may not lead to the expected behavior.One solution to this problem is to hold the
Store
using@StateObject
. To do this, theStore
must conform toObservableObject
. I would like to know if there are any issues with havingStore
conform toObservableObject
. Additionally, I am interested in the pros and cons of havingStore
conform toObservableObject
at the time of its definition.Beta Was this translation helpful? Give feedback.
All reactions