How to integrate _AppStorage with TCA? #64
-
The I tried to include a struct State: Equatable {
@Dependency.AppStorage("mySetting") var mySetting = 100
// ... other state
This will give a compile error. But it does not seem to make sense to make Also I do not understand how I am expected to update an As a third issue it is not trivial to observe a changing Anybody have suggestions or has already successfully used |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hey @tkunst891! In my mind, you would use it in the reducer and use its async sequence to update a local value. The sequence always emit on "connection", so you can use it to set your initial value. So you'd produce early a .run { send in
for await p in self.$pref {
await send(.pref(p)) // An action that sets `pref` in your state.
}
} If you only want the value without observing it, then I agree that the side effect is not optimal. If you want to avoid it, you can also fish the value in a
|
Beta Was this translation helpful? Give feedback.
That being said, this feature is experimental, so suggestions are welcome!