Using @AppStorage with AppState #1302
Unanswered
Dominic263
asked this question in
Q&A
Replies: 1 comment
-
One of the goals of this architecture is testability. If you use @AppStorage directly in views you loose the testability. Instead you can put an endpoint in your environment to store and retrieve your bool, add the bool to your state and have action to fetch it when needed or even observe it. This way you can have a mock/preview/impl of this dependency as any other dependency in TCA. That said if you don't really care about testing this, you can use it directly in your view. Plain SwiftUI wrappers work well when mixed with TCA views. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
quick question.
How do you use @AppStorage in a TCA app to say, save user default information. For example, I have an idea to use @AppStorage to store a Bool that says whethere or not the user has gone through the onboarding screen before and go straight into the login screen if that is the case.
Beta Was this translation helpful? Give feedback.
All reactions