Mastering MVVM With Swift

Why RxSwift

Before we refactor the AddLocationViewViewModel class, I'd like to take a few minutes to explain my motivation for using RxSwift and RxCocoa. There are several reasons.

It's a Library

RxSwift is a reactive extension for the Swift language. ReactiveX has been gaining in popularity ever since Rx.NET was open sourced several years ago. Reactive extensions are available for many languages, including Java, C#, JavaScript, and Python.

What I like about ReactiveX is that it doesn't force you to adopt a particular architecture. You can use Rx without using the Model-View-ViewModel pattern. You should see Rx as a tool, not an architecture.

Testability

RxSwift has been around for quite a while and it's a robust implementation of the ReactiveX API. It's fantastic to use and the more you use it the more you experience the power and versatility of ReactiveX.

The RxSwift team has invested heavily in testability, making it easy to test reactive code. In a later episode, we test the reactive code we write and that'll show you how important this is.

Powerful and Versatile

While RxSwift has no relation to the Cocoa APIs, there is an extension for Cocoa, RxCocoa. Most of the UIKit components you use day in day out are reactified. In the next episodes, you find out how that works.

The combination of RxSwift and RxCocoa is amazing. If you're new to RxSwift and RxCocoa, then I encourage you to give it a try. I hope the next few episodes can convince you to take a closer look at RxSwift and RxCocoa.

Next Episode "Integrating RxSwift and RxCocoa"

Stop Writing Swift That Sucks

Download the Swift Patterns I Swear By