Perform Networking using ObservableObject
SwiftUI Mastery Travel Discovery
In SwiftUI, you're often tasked with fetching data from the Network. In this lesson, I'll introduce ObservableObject that allows us a safe area to perform this type of work. Also with the addition of @Published variables, we can easily update our UI once this work is done.

Comments (4)
Aidan Egan
2 years ago
Hey Brian, I have done some projects so far using SwiftUI and used a very similar approach like you had with the ObservableObject ViewModel class however I call mine a store so in this case it would be CategoryDetailsStore. I got this MVC styled approach from a medium article (https://medium.com/movile-tech/swiftui-and-architectures-mvc-9af08239c116). Is the pattern you are going to use for the travel discovery app MVVM ? Thanks, Aidan
Brian Voong
2 years ago
dniswhite
2 years ago
the learning time was fun and challenging but... watching your video here it looked your views on the destination for each navigation link were being created when you clicked them. so in my testing I was wondering what was happening? then I realized these views are not lazy created. =( did some digging and came across the following: https://medium.com/better-programming/swiftui-navigation-links-and-the-common-pitfalls-faced-505cbfd8029b then I came back to ask about this and realized there was Lesson 13 that actually talked about the issue. and gave a link to SO with an identical solution. Just a recommendation but moving Lesson 13 up a bit more would be interesting... or maybe just talk about an upcoming solution?
Christopher J. Roura
2 years ago
Is there a difference between @StateObject and @ObservedObject? I have seen some devs use State vs Observed but to me both seem to do the same.
Brian Voong
2 years ago
Christopher J. Roura
2 years ago
Thank you!
KyloR_
2 years ago
Hello, is there a difference between using the UIKit UIActivityIndicatorView vs the SwiftUI ProgressView, or did the ProgressView just get added after the lessons were recorded? Thanks!
Brian Voong
2 years ago
HELP & SUPPORT