Observable objects

Next, we are going to look at observable objects, and by observable we mean models that can change state or be updated due to an external API call. For example, a model that houses weather information from a weather API might get updated periodically. We would want our UI (or SwiftUI, in our case) to monitor this model for any changes and implement updates accordingly.

To dig a little deeper into how MVVM works with SwiftUI, let's write a small application that takes some data from an external API, parses the data, and then displays the data within our app.

ObservableObject is a protocol that is part of the new Combine framework, which was announced alongside SwiftUI at WWDC 19. Combine is Swift's own version of Reactive ...

Get Learn SwiftUI now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.