Skip to content

Testing MVVMÇ concepts with SwiftUI#2

Open
MP0w wants to merge 1 commit intomasterfrom
swiftUI-test
Open

Testing MVVMÇ concepts with SwiftUI#2
MP0w wants to merge 1 commit intomasterfrom
swiftUI-test

Conversation

@MP0w
Copy link
Owner

@MP0w MP0w commented Sep 11, 2019

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)

@monchote
Copy link
Collaborator

monchote commented Mar 3, 2020

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

@MP0w
Copy link
Owner Author

MP0w commented Mar 3, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants