RxSwift has been around for many years, but it isn't the only option you have. In 2019, Apple introduced Combine, a system framework that brings reactive programming to Apple's platforms. The framework provides a declarative API for processing values of time.

Before I show you how Combine plays with the Model-View-ViewModel pattern, I want to take a few minutes to list the pros and cons of Apple's framework. Combine is still very young. RxSwift has been around for many years. Why would you choose Combine over RxSwift?

It's First Party

Every dependency is a potential liability. That is a fact. Not all dependencies are equal, though. Combine is a system framework, which means that it is tightly integrated into the system and it can offer functionality other solutions might not be able to match.

Third party dependencies always introduce a risk, large or small. Even though RxSwift benefits from a vibrant community and is built and maintained by a healthy group of active contributors, it is a third party dependency. What will you do if the project is no longer maintained? This won't happen in the near future, but it is a factor you must consider when you choose to integrate a dependency into a project.

Combine is a first party framework, built and maintained by Apple. This has pros and cons. Combine is an integral component of the SwiftUI framework. This is great because it means Apple is eating its own dog food. Combine will only get better and it won't be deprecated anytime soon. Apple markets SwiftUI as the future of rich, reactive user interfaces. That is good news because it implies that Combine also has a bright future.

Combine also has a few drawbacks. The framework is closed source. Bugs need to be fixed by Apple. This is a slow process, especially compared to most open source projects. You can extend the framework's capabilities to some extent. You can for example implement custom operators. There are limitations, though. Because Combine is closed source, Apple is in control.

Adoption

You may need to wait before you can adopt Combine. The framework requires iOS and tvOS 13 or higher, or macOS 10.15 or higher. This means that many developers will need to wait a few more years before they can start integrating Combine into their projects.

Learning Curve

Combine is inspired by Rx. This means that the learning curve isn't steep if you have some familiarity with other Rx extensions, such as RxSwift or RxJava.

RxSwift has been around for many years. Its API is rich and flexible. Combine is a more basic implementation. Its vocabulary is limited. This means that the learning curve is less steep, but it has a few limitations RxSwift doesn't have. This isn't a problem, but it is a factor you need to consider if you plan to switch from RxSwift to Combine.

Learn It

Combine is Apple's answer to the gaining popularity of reactive programming. Once you start using reactive programming in a project, you will wonder how you ever built software without it.

Because it is a system framework and a key component of SwiftUI, Combine will become a required skill in a few years. The sooner you can adopt it the better.