MVVMC icon indicating copy to clipboard operation
MVVMC copied to clipboard

Testing MVVMÇ concepts with SwiftUI

Open MP0w opened this issue 6 years ago • 2 comments

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)

MP0w avatar Sep 11 '19 16:09 MP0w

Looks good @MP0w! But can we keep the old example too? Most people won't be using SwiftUI for a while.

monchote avatar Mar 03 '20 12:03 monchote

Yep was just a test 😬 Actually I will try out soon in a project so I will see if the approach is good

MP0w avatar Mar 03 '20 12:03 MP0w