How do we bind the various components of the Model-View-ViewModel pattern together? That is the question we focus on in the next few episodes. It is a problem most developers new to the MVVM pattern struggle with. It isn't difficult to use the Model-View-ViewModel pattern to push data from the controller layer to the view layer. We already covered that extensively in this series. What do we need to change to automatically update the user interface if the user interacts with the application or the environment changes?

Earlier in this series, I explained that the origins of the MVVM pattern lead back to Microsoft's .NET framework. Bindings are built into the framework and make it trivial to bind the various components of the Model-View-ViewModel pattern together. They are a key ingredient of the MVVM pattern and that is why it is sometimes referred to as the Model-View-Binder pattern. Bindings make sure that the view layer and the model layer are synchronized.

It is possible to implement the Model-View-ViewModel pattern without bindings by writing glue code. But that isn't an option I can recommend. We don't want to manually push changes from the view model to the view controller's view. That is the task of the view controller. But that is exactly what we want to avoid. Right? We want a better, more robust solution.

Unfortunately, Swift doesn't have built-in support for bindings. You can roll your own implementation using closures or key-value-observing. I like to refer to these solutions as DIY bindings or Do It Yourself bindings. We start with this solution to better understand how the various pieces work under the hood. But DIY bindings don't scale and they aren't terribly elegant. Complex applications need a flexible and more powerful solution.

There are several options available, such as Bond, RxSwift, and ReactiveCocoa. The solutions we explore in this series are RxSwift and Combine. RxSwift is the most popular third party option and the one I have come to appreciate over the past few years. It is easy to pick up. The Combine framework was introduced in 2019 and it is Apple's response to the growing popularity of reactive programming.

I want to emphasize that you don't need to be familiar with RxSwift or Combine to understand the next few episodes. The emphasis of the following episodes lies on the implementation of the Model-View-ViewModel pattern, not understanding RxSwift or Combine. This also means that I won't explain the details that relate to RxSwift or Combine in great detail. You can use any bindings solution you like, including a custom one.