Chapter 16
Working with Observable Objects and Combine
Failure is an option here. If things are not failing, you are not innovating enough.
– Elon Musk
In the previous section, we introduced the Review screen, which allows users to rate a restaurant. However, the rating buttons currently lack functionality. The desired behavior is for the review view to dismiss itself when a rating is selected, and for the selected rating to be displayed in the detail view. In this chapter, we will delve into the implementation details of this functionality.
On top of that, I will provide you with a brief introduction to Combine, a framework that was introduced alongside SwiftUI. Combine allows for easy observation of a single object and receiving notifications of its changes. When combined with SwiftUI, we can trigger view updates without writing any additional code. SwiftUI and Combine work seamlessly together, handling everything behind the scenes.
To access the full version of the book, please get the full copy here. You will also be able to access the full source code of the project.