Elm architecture in iOS

What were you the god of again?

When you think you are the god of RxSwift and MVVM

Let’s get shit out of the way

RxSwift is dead, MVVM is dead. Killed by Hela… I mean Swift.

This is what you should do

An iOS developer improving his skill using the power of Swift (colorized)

Aren’t you tired of useless shit thrown at your face?

Say you are beginning as an iOS developer in early 2019.

MVVM developer circa 2019

What is the problem

Swift is an evolving language.

Admit it, you opened your palm

Elm architecture

The google top result for “Elm architecture in iOS” is a medium article talking about how to use RxSwift.

var title: String {    didSet {        label.text = title
}
}
Just a property observer

msg -> Model -> View -> msg

where msg is used to update model.

  1. You can use property observer to build view as function of Model which may be a component of overall State.
  2. You have one way binding from model to view. And that is good enough for most use cases. Because user interaction has side effects, hence often cannot be described by binding. Instead view processes user interaction and generates messages to update model. Side effects on view also appear as messages that update model.
  3. Network requests produce delayed message to update model. A major design difference with MVVM. Why put networking inside model when you can keep model simple and value-typed? You may argue that networking makes view controller complex which is what motivates MVVM in the first place. But what makes your networking complex? If it is complex, and you move it to view model, doesn’t that make your view model complex? Have you tried making it less complex? By an ancient technique called refactor? What about protocol extension?
action(.msg) // this function updates model
What were you god of again?
struct Model: View {...}

Ragnarok

Or as I called it, paradigm shift.

When Elm meets POP

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store