Learning about Combine using examples
Up until now, we have discussed several Combine components and delved into understanding how Combine works underneath by creating our custom publishers, subscribers, and operators.
Despite that, many developers need help incorporating Combine frameworks in real-life scenarios.
The different publishers and operators are mostly clear in theory, but it can be difficult to imagine them as part of the central design patterns we use in our projects.
Let’s review some examples to help us understand how to implement Combine in our projects. We’ll start with a basic example of managing a UI state in a view model.
Managing UIKit-based view state in a view model
SwiftUI view states are naturally declarative. This means we can bind the view state, such as a list of items, to a UI component, such as a List
view. That’s the only way to handle states in SwiftUI.
However, achieving that design pattern in UIKit takes time...