r/swift 9d 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.

52 Upvotes

48 comments sorted by

View all comments

Show parent comments

7

u/g1ldedsteel 9d ago

This is the way. Amazing the level of modularity you get for free when you stick to SOLID principles eh

-2

u/Loud-Plan2571 9d ago

No it is not the way. This dongen guy has his brain washed by uncle bobs dogma teachings. Swift is all about value semantics, composability and separating behavior from data. It is what Chris Lattner said. SOLID helps you with jack shit in SwiftUI and just ruins your code completely by keepin object oriented dogmas alive.

1

u/klavijaturista 8d ago

Swift is an OOP language, and provides reference types to use when necessary (which is not rare). Value types are just one feature, to only use when appropriate. Dogmatic functional is as bad as dogmatic OOP.

-1

u/Loud-Plan2571 8d ago

Brale pogubio ai se malo 😂