Introducing Combine in a SwiftUI project
In this recipe, we are going to add publish support to
CLLocationManager will emit status and location updates, which will be observed by a SwiftUI View. It is a different implementation of the problem that is presented in Chapter 8, Implementing a CoreLocation Wrapper as @ObservedObject.
In this architecture, the view doesn't have any logic. That is instead encapsulated in the intermediate object, the ViewModel, which has the responsibility of being the model for the view and talking to the business logic model, services, and so on to update that model. For example, it will have a property for the current location that the view will use to present it to the user, and at the same time, the ViewModel will talk to the LocationService hiding that relationship to the...