MVVM in iOS Development with Protocol + Closure + Reactive Programming(RxSwift)

Yusuf Demirci
3 min readFeb 24, 2021

Yusuf is an iOS developer who has just started his career in iOS development. He starts building apps with MVC as Apple suggests. After a while, he wishes to go deeply through the development. According to his researches, other developers use MVVM with various architecture extensions. While some of them prefer MVVM + Protocol, others want to use Closure or Reactive Programming with MVVM. Let’s help Yusuf to find out what kinds of differences exist in these approaches in a project.

What is MVVM?

It’s the architecture that simply brings View Model over MVC. The idea behind it that moving logical conditions into the view model from the controller. Is it easy, isn’t it? To be honest, yes. Yusuf is just supposed to create one class which is called view model.

Before going to the project deeply Yusuf must know these,

  1. There must be only business logic in the view model. Don’t import UIKit ever!
  2. The view model must be eligible to test. Pass the view model via injection through the init function of the controller.
  3. Service calls must be in the view model.

Yusuf has created a cryptocurrency ticker project which includes 2 screens. The list screen shows the list…

--

--