Migrating SwiftUI MVVM App to MV Pattern

Migrating SwiftUI MVVM App to MV Pattern

azamsharp

10 месяцев назад

4,447 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@robinandthedog
@robinandthedog - 31.12.2023 15:13

Great video, my last two applications are using this approach, only after time when they become too large I need to refactor in multiple models, like you are suggesting here.

Ответить
@alenayoutube1574
@alenayoutube1574 - 21.12.2023 16:14

i got recommendation now but good explanation....thanks for the knowledge

Ответить
@porroapp
@porroapp - 20.12.2023 14:41

Coming from React background, where we have context providers, this seems more natural way to code in SwiftUI instead of having a ViewModel for every View. I can just have a global model for my context and pass it down as an EnvironmentalObject which suits me just fine. And I can access the model/context methods/functions from any child view that is bound to the environmentObject. Thank you for explaining the key difference between MVVM and just MV which was driving me crazy as so many other videos lack the coding example you've shown.Thank you!

Ответить
@muhammaddanishqureshi160
@muhammaddanishqureshi160 - 20.12.2023 12:46

Hi @azamsharp Azam,
I hope you will be fine and doing great things,
I have question about the Aggregate Model, you are saying that we need to use only one model, and not use viewModel for every class.
Okay I accept that, but with your approach we are killing the SOLID principles, With approach you told us in the tutorial, Our Aggregate Model class has more than one responsibility, if we need to check some other things or bring things from the Server than we will add that these things in the Aggregate model again, and it will be the another responsibility of that Aggregate Model.
My question is how you will justify with the SOLID principle "S" that stands (Single Responsibility Principle)?
I hope so you will answer a good and healthy way.

Ответить
@jordancalhouncom
@jordancalhouncom - 15.12.2023 02:54

ScoobyDoo.swift has entered the chat

Ответить
@binay.kumar.sharma
@binay.kumar.sharma - 10.12.2023 15:00

nice

Ответить
@cristianf98
@cristianf98 - 24.11.2023 15:54

Hi Azam, thank's for the video, is really well explained and thought. Hope will contribute to get more people out of the trap of MVVM.

Your aggregate models seem a lot like what Siesta was doing back in the days of UIKit, basically a resource based networking approach where each collection of the backend would be modeled as a stateful observable resource able to retrieve itself and shared within the app so UI is kept in sync.

I would suggest taking a look, I've not used it yet (I discovered it recently) but seems like an excellent approach for those who still need to use UIKit and could be useful as inspiration for those who plan to rely on SwiftUI basic SDK instead of intrincated architectures.

About the ActiveRecord pattern, have you considered using protocol extensions for automating fetching on the entities? With protocol extension + ObservableObjects you could easily do what Siesta does on SwiftUI. Regards!

Ответить
@vcastroc
@vcastroc - 25.10.2023 17:24

Azamsharp, what is the tool that you use to mark when you explain?

Ответить
@study2368
@study2368 - 18.10.2023 10:38

Great video! Can you help understand does this approach violate single responsibility principle from SOLID? I see Apple is making similar models in their sample SwiftUI apps, but I am still confused and don't understand if this is safe.

Ответить
@KFrench1123
@KFrench1123 - 17.09.2023 03:58

I like it! I'm going to give it a try in my current project, I've been frustrated recently with MVVM

Ответить
@subinsuresh
@subinsuresh - 19.08.2023 20:58

AddOrderscreen doesn't require loadorder method. But it can access that method too..

Ответить
@gildas_dev
@gildas_dev - 19.08.2023 14:07

In our application we called the aggregate class "Provider". The provider is tight to a domain. Examaple, everything related to "client" will be placed there. The state are publishers. The publishers on the provider will be used by our ViewModels. We use viewModels because for us the purpose of a viewModel is to manage the view only, thus is necessary.

Ответить
@linkonsid8883
@linkonsid8883 - 15.08.2023 16:11

I have a concern with this approach. Lets say we have 3 views- ViewA, ViewB and ViewC. We will be using one Aggregator Model for all of these views according to your idea. Lets assume all the views need different properties to load into them. So our Model has all those different published properties. In that case, ViewA will be able to access the other properties needed for ViewB and ViewC and vice versa. And in my opinion, this is a bit unnecessary, after all we encapsulate things to make them hide from the outside world. So ViewB should not know anything about ViewA or ViewC unless they are connected somehow. I hope you clear these things

Ответить
@savagedirk9267
@savagedirk9267 - 15.08.2023 15:38

Using extensions of your base model could let you setup “domains” for functionality on larger projects. Not an original thought but one nonetheless.

Ответить
@fpseverino
@fpseverino - 15.08.2023 01:04

This video literally came out in the perfect moment!! Thank you a lot! Do you by any chance have published the project in a public repo?

Ответить