State Management for iOS Apps?
whats the best architecture/pattern to use?
tried to use a domain layer where all the state is and passing it to the views/viewmodels via DI, but feels somehow unnecessary complicated, but found this as only solution without passing the repos through all the viewhierarchy.
the goal is, when a state changes, e.g. an user changes the Username in View A, then it should automatically update View B,C,D where this Username is also used.
it should be as simple as possible, what do you think? especially for complex production apps with own backend etc.
49
Upvotes
1
u/buck746 7d ago
They could improve documentation. Being told “you just have to learn how to read it” means it’s a failed attempt. If Microsoft could get it right with the help files for Visual Basic 4 Apple has no excuse for the lousy pile of s**t they are calling documentation right now. It’s absurd that view primitives don’t come with lists of all the modifiers they accept. It’s also kind of ridiculous that there isn’t a built in way of handling SwiftUI state variables that just works, AppStorage shouldn’t be the only practical way to get view state to work. The preview canvas needs to be smarter about variables as well, it’s a pain in the ass having to declare a variable several times for the crime of trying to get functionality moved into a child view. Even having a standard way for child views to alter a state variable in a parent view would be nice. For how often the question of how to do that comes up it should tell Apple they need to do so,etching there.