Drawbacks of ViewModel class inside view extension in SwiftUI

preview_player
Показать описание
In this session we will explore the drawbacks of creating a viewModel class inside a view extension in SwiftUI. The two drawbacks of the approach makes it misleading because you loose test-ability and re-usability.

Given are the chapters of this video
0:00 introduction
0:11 general idea
0:51 code walk-through
1:29 words of wisdom
1:53 tight coupling between view and viewModel
3:47 mixing of UI and Unit test case
4:13 no re-usability
5:01 conclusion

#swiftui #swiftuitutorial #mvvmSwiftui
Рекомендации по теме
Комментарии
Автор

In the test cases, you could directly access the viewModel without creating the instance of the ContentView but still we would have the same problem, the VM are not independently testable and resuable.

ioscafe
Автор

I don’t know why some people recommend building the VM inside the extension it makes no sense…

jdotseven
Автор

I think this idea to create ViewModel class inside a view is violating the rules of MVVM architecture?

ashokkanwal
join shbcf.ru