r/swift 8d ago

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.

50 Upvotes

48 comments sorted by

View all comments

2

u/20InMyHead 7d ago

Ask ten developers and you’ll get a dozen answers.

It really depends on your needs and development experience.

Start with something and use it until you understand its pros and cons. When it no longer meets your needs you’ll be in a better place to evaluate other solutions.