kodecocodes / swiftui-example-app-koober

Porting the example app from our Advanced iOS App Architecture book from UIKit to SwiftUI.
59 stars 11 forks source link

SwiftUI view depending on abstract #9

Closed kelvinlauKL closed 5 years ago

kelvinlauKL commented 5 years ago

Checklist

Description

Been doing some experimentation on having SwiftUI views to depend on an abstract model. The model could then be injected and have mock representations for testing.

Pros to this approach

Cons

var _email = ""
var email: Binding<String> { return .init(getValue: {  self._email }, setValue: { self._email = $0 }) }

Asking for opinions on whether this is a good idea or not. Relevant thread with some opinions from Joe Groff: https://forums.swift.org/t/state-messing-with-initializer-flow/25276/8

RCacheaux commented 5 years ago

I really like this. I think we can build on it and iterate on it. This gave me an idea for how to combine MVVM, use cases, and a bit of Redux for a really nice clean architecture. Go ahead and merge this in and I'll raise some PRs branching off.