8 ms·
I recently started learning Swift and Swift UI and was surprised at how complicated the language is. Especially regarding reactive instance variables. eg. @obse
by neillyons 2y ago
I recently started learning Swift and Swift UI and was surprised at how complicated the language is. Especially regarding reactive instance variables. eg. @observableObject. Didn't understand it. There are like five different ways to do it. Ended up playing whack a mole until it worked.
- gavindean90 2y agoI had the same experience until I worked with swiftdata which was rather nice, especially by comparison.
- jamil7 2y agoIf you’re targeting newer OSs you can try the @Observable macro instead of ObservableObject. It fixes a lot of the weird problems with the latter (although does introduce some new, weird edge cases).
- SebastianKra 2y agoTBF, reactivity in UI is still basically an unsolved problem with frameworks going in circles between data-binding, dependency-tracking, memoization & compilation. SwiftUI initially promoted their ReactiveX alternative.