Massive view controller a.k.a view model in SwiftUI

“It’s not possible, perhaps you saw burnt concrete?”

Let’s create a meltdown… I mean massive view controller

Here’s what I’m going to do in this article.

Safety first, raise the power

struct ReactorView: View {
@State var reactor = Reactor()
@State var graphite = NotThere()
var body: some View {Text("3.6 roentgen")}
}
class ViewController: ObservableObject {...}
struct ReactorView: View {
@ObservedObject var vc = ViewController()
var body: some View {Text(vc.roentgen)}
}

You didn’t see graphite

MVVM is the culmination of decades of hard work by industry titans, influencers and skilled veterans.

struct ReactorView: View {
@State var reactor = Reactor()
@State var graphite = NotThere()
var body: some View {Text("3.6 roentgen")}
}

It’s not 3 Roentgen it is 15000

You can tell SDK has built-in support for ReactorView to work as the model side of a model-view binding, because you have @EnvironmentObject, @State, @StateObject, @ObservedObject… etc there.

How does a RBMK reactor explode?

Let’s examine 3 of the top google results for “swiftui clean architecture‘.

Cleaner architecture

What is the cost of lies?

I’m going to wrap up with the third example that I want to talk about.

--

--

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