Hacker News new | ask | show | jobs
by neillyons 632 days 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.
3 comments

TBF, 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.

If 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).
I had the same experience until I worked with swiftdata which was rather nice, especially by comparison.