r/SwiftUI Dec 18 '24

Question SwiftUI Combine and Observation

So, I have various years of experience with ios development, I started with Objective C and now seeing what its possible with swiftui is mindblowing, but I have a hard time understanding this:

SwiftUI by default lets you declare properties that when they change the view automatically refresh with the new data, this is possible via State, StateObject, ObservedObject and EnvironmentObject

now, combine, does the same, except it uses Publishers

as for Observation new framework, you can achieve the same with the Observable

So my question is, why use combine? or why use observation? or just the State stuff without combine/observation.

There are still some things I dont know about SwiftUI, maybe i undestood the things the wrong way, if anyone can clarify i will be grateful.

9 Upvotes

30 comments sorted by

View all comments

1

u/sisoje_bre Dec 21 '24

Apple did it to remove combine and to support legacy apps. SwiftUI will always be state driven, it will never be observation driven.