Why Should We Use RxSwift?

Swiftos
3 min readOct 19, 2020

Hi iOS Developers,

I guess you must have heard about Apple announcing the Reactive Programming (aka Rx) framework called Combine. Therefore, Reactive Programming has become a very oriented topic for iOS development. Today, we are going to talk about the biggest Rx library for iOS — RxSwift.

What is RxSwift?

Rx is a generic abstraction of computation expressed through Observable<Element> interface.

by https://github.com/ReactiveX/RxSwift

Why RxSwift?

If your application reacts a lot to user integrations, RxSwift is here to clean up your massive codebase. Let’s take a look at an example of what does it look like with RxSwift.

Example:

Let’s say you are building a “like” feature that allows users to like posts. And you want to update the UI correspondingly.

Without RxSwift:

var isLiked: Bool = false {
didSet {
updateUI()
}
}

With RxSwift:

let isLiked = Variable(false) isLiked.asObservable().subscribe(onNext: { 
updateUI()
})

let’s say you have a huge block of code inside the updateUI function. For example, you’d only want…

--

--

Swiftos

I publish short iOS development tutorials on a weekly basis. For all content, head over to: https://www.patreon.com/Swiftos