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

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?

MVVM developer circa 2019

What is the problem

Admit it, you opened your palm

Elm architecture

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

msg -> Model -> View -> msg

  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

When Elm meets POP

--

--

--

Casual iOS developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to know when will my Spring Boot scheduled job will trigger next time

🤖 @SpaceGate_fi presents the second #YOLOS report with the incredible income procedure that ends…

Top git commands every programmer should know

Common Security Issues in Web Applications. Part 1

Cloud computing and AWS

How to write alt texts for images?

Learn HTML In This Way

How to learn HTML / CSS / JS from scratch, without a mathematical background, without a clue what…

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
Jim Lai

Jim Lai

Casual iOS developer

More from Medium

How to fail miserably with RxSwift + MVVM

Resolve a question about pthread_rwlock_t

Reactive MVVM Pattern in UIKit

Unit Testing in Swift using (MVVM and RX)