Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I did some tests to adapt MVVMÇ concepts to SwiftUI, I think the advantages of MVVMÇ are still valid with SwiftUI, the immutability of Views add even more benefits and change a bit how you can handle things.
This is just a test and initial approach to try it out.
As View don't have state anymore now you can hold the state in
@State
properties while still keeping the ViewModel layer immutable and handle it in a similar way as before:State never gets propagated to the VM/Interactor until it actually needs to affect the ViewModel (e.g. saving a form).
This tests doesn't really involve the View state but is more about the basic approach of binding the Interactor with the View to replace VMs when the model changes. Now can be done using
Combine
framework and using SwiftUI's property wrappers that are needed in order to update the View when something changes.WDYT? @monchote @joanromano @polqf @ilozano
(pinging random people that used MVVMÇ in past or present)