Hacker News new | ask | show | jobs
by gregkerzhner 2311 days ago
I think the thing that is very tempting to do is to just have a ViewModelDelegate (which would be the controller) that has one method `func stateChanged(state: ViewState)` and then have the controller rerender itself whenenver that function is called. This would be nice and redux-y since the view could be a pure function of the state. But since iOS doesn't have a declarative user interface or the virtual dom, you would potentially be rerendering the whole screen when just one part of it needs to change. How do you guys overcome that? Or do you have multiple delegate methods that the view model calls on the controller depending on what needs to happen?
1 comments

I don’t have much experience in iOS/Swift, but would SwiftUI address the declarative part?

From what I’ve seen you can supply state to a view and it’ll take care of the rendering for you.