Hey, I got the same idea when I started working on our SwiftUI/ Combine project a year ago. However, I left the names as it is. Observed is still the ViewModel, Identifiable is still the Model in our architecture. This combined with a variant of clean architecture for our Combine pipelines has made our codebase so neat and intuitive.
Dont think this pattern has clean ios arch, it's already breaking SRP in the view, the view has to talk to network layer, there's no separation of concerns, nor dependency injection this is not testable.
There is no difference from MVVM and what you've described here apart from just putting a different label/name and made such a big claim to "STOP using MVVM". Was expecting at least some challenging arguments and new solutions exclusive for SwiftUI. We us this in our projects.
Good point Jonas. I just wanted to present a SwiftUI specific architecture that I use. BTW Do you know the 60-30-10 Rule of Coding? Check it out here: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-0ZH2HmMAD5E.html
Nothing much. That alone makes it super safe and SwiftUI like. Do you love SwiftUI? Let me tell you the 7 things I HATE about SwiftUI: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-N2i28zxjfvs.html
Kinda, but there's more to it. BTW are you using keychain to secure your data? Watch this video where I explain how easy it is to use keychain in Swift: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-csssezPchoI.html
That is correct. Being that said IVO is a bit closer to the SwiftUI jargon :) BTW here's a must watch for iOS developers: Clean Code Principles ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-2lD8fjedeis.html
@@rebeloper Thank you. By the way, when I saw this video I thought it was a bit silly but now I definitely agree - IVO is much cleaner compared to MVVM, going to use this from now on.
Correct. More restrictions, much more readable, SwiftUI like :) Till than take a look at my lates video about 30 Xcode Keyboard Shortcuts You NEED to Know: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-CWjHI3vZLSk.html
He’s just creating flat scopes that will inevitably cause massive memory and scoping issues for redrawing once you have to add more than a single screen to your test app. Would not recommend doing anything similar to this. There’s really no pattern here, and the way he’s managing the view model makes me think he doesn’t even understand why you’d want a view model in the first place or how you’d write tests to cover this monstrosity
Recently I've been using custom property wrappers instead of MVVM :) Did you wonder if will AI replace programmers? Check out my take on it 👇 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-9NlECBGI-OM.html&ab_channel=Rebeloper-RebelDeveloper
If you return something that is unstable, like UUID() or an index, this means you get a new object each time you get the object and this will kill reusability and can cause epic memory and layout process usage beside view management issues like transition management and etc.
Why I like the concept for it simplicity it may end up creating difficulty for a medium or large project. The layers are tightly coupled so maintaining the code will become a big issues quickly. I always advocate for separating business logic from every other layer/part of your code and business layer should never depend on any concrete implementation of any other part of your code.
I couldn't agree more, Paul. BTW Here I talk about The Harsh Reality of Being a Software Engineer 👉 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-IxweswL5SjI.html
I like to have them also in the View and complete/throw with optional errors so I can show the on the View as an Alert :) Of course the logic should definitely be done on the view model. If you enjoyed this video make sure to check out my newest tutorial about iOS15 availability: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-u1SMCxmYMvE.html
@@rebeloper is it also okay to have another observed value within the extension that has a cleaner payload of erro? So one can just mutate view depending on the cleaner observed Error?
This doesn't changes anything to MVVM, is the same pattern with different naming conventions. Observable could just be @State, and profile doesn't need to conform to Identifiable if you're not going to use that conformances for something, like display the fetched entities in it in a list, which is not the case since your fetch fetches a single profile.
It makes it more robust :) Next watch Xcode Meets AI: Take Your App Development to New Heights 👇 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-xwcPYSezBxA.html&ab_channel=Rebeloper-RebelDeveloper
Thank you for this tutorial. It is the cleanest and easiest to understand. I've viewed many MVVM tutorials, and they are usually convoluted by using components that detract from the basic inter-file communication. This makes it more overwhelming to visualize. Your example is straight and to the point, with no distracting "extras". I also really like your teaching style, and look forward to following more of your tutorials. Thanks again!
Thank you for the kind words. Glad you like my teaching style. I also do 1:1 mentoring: rebeloper.com/mentoring BTW Find out How to Create Custom a Framework in Swift within minutes 👉 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-2k4mMdLfIKY.html
It's just personal preference :) both work fine. If you liked this one you will love my latest video on Timers: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-oo-sW_Ds968.html
Hello, thanks for the explanation, I applied it in a demo that I am making to practice SwiftUI, but I have a doubt, Could you give me an example of where I should declare an EnviromentObject? would it be inside the View or inside the Observed class?
Let me explain in detail in a mentoring session rebeloper.com/mentoring Best iOS Development Tools - Summer Sale 👇 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-HzGgXjyF8ak.html
Thanks for the suggestion. Will consider it. Next watch Mastering App Distribution With TestFlight And App Store Connect 👇 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-GyD6t0GnWp0.html&ab_channel=Rebeloper-RebelDeveloper
HI Rebel! Im new-ish in iOS dev, curious to know use cases for this pattern? Should I use this for my job or personal project? I do like how this reduces the amount of models (or view models) to create especially if the Model or ViewModel is for that specific View only while at the same time easier to set up in the beginning. This almost feels like MVVM, with the difference of naming and access. Is this still easy to test?
Either use @environmentObject or move it into the Views with @ObservedObject. I can show it to you in a mentoring session: rebeloper.com/mentoring BTW check out this New MUST HAVE SwiftUI View 👉 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-qJNy-u5gbq8.html
For that case I would set up the shared ObservableObject as an environment object. Next Unlock the Power of Core Data Versioning! 👇 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-RDtLWWos3cA.html&ab_channel=Rebeloper-RebelDeveloper
You have to learn the pros and cons so you can decide if and how you're going to use it. Did you wonder if will AI replace programmers? Check out my take on it 👇 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-9NlECBGI-OM.html&ab_channel=Rebeloper-RebelDeveloper
Works exactly the same. No changes are required. BTW are you using NavigationView or NavigationStack in your SwiftUI projects? STOP using Navigation Stack in SwiftUI! Use THIS instead... 👇 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-LR0uK5Mc2CM.html
You seem to be promoting MVVM, even though you say otherwise. One of the hallmarks of MVVM is testability, and I find it odd that the folks taking the time to write articles about why MVVM doesn't work with SwiftUI, conveniently leave out how one might otherwise unit test their code.
You're perfectly right. My suggestion is MVVM just pinpointed for SwiftUI specifically. Also yes, testing is great with MVVM. Next: Make Sure You Always Get the Best Error Alerts! 👇 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-VWgZ99FTuBU.html
In some cases you do need a VM. But mostly it's just the View. BTW check out these 8 Mind-Blowing Websites You Probably Didn't Know Existed 👉 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-BGJgBjnCSM0.html
I do not use MVVM at all with CoreData. The property wrappers provided by SwiftUI are more than enough, so I use only the views. SwiftData is even easier. BTW have you seen Firebase Login in SwiftUI: Step by Step Masterclass 👇 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-9lRWau51lGw.html&ab_channel=Rebeloper-RebelDeveloper
Yes, you are right. Made it really "tight", SwiftUI specific. BTW here are 6 things I wish I knew about SwiftUI when I started 👇 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-EZz9NL4H0Ug.html
You can do it, Thomas! Let me know if you have any issues. BTW are you a PRO developer? TRY THIS: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-fw8NIizbYMU.html
This looks very interesting. Will try it out. You *almost* addressed something which I've been struggling with, so I'll ask you here..... Hope you don't mind. Many apps have a sign-up/sign-in ability and then a User Profile page that can be filled in. But....what if the properties in the User struct are optional? Mine has `name` and `email` as Strings, but then I have 5-10 other properties which are all optional: dateOfBirth: Date?, gender (an optional Enum), heightInCM (optional Int), and more. Following Peter Friese's Books app, I like the idea of having one view to display the User Profile and clicking "Edit" to update the User's properties. But, if the user edits their profile but only adds *one* value, say their birthdate, and doesn't change the other values, how will they maintain their nil values? I can fake it for anything that uses a TextField, but for Pickers, Toggles, etc....there doesn't seem to be a useful, non-clunky solution. If you have any thoughts, ideas, suggestions - even other places I could ask that are not as judgemental as SO - I'd be happy for any pointers. Thanks again for you interesting video.
Take a look at BetterCodable on GitHub. It addresses the exact issue you are having. If you need me to explain I'm available here: rebeloper.com/mentoring BTW do you want to know why 95% of self-taught developers fail? Find out why here: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-pZaot8RA84g.html
Sorry, SwiftUI is not going well with Test... for now. BTW Becoming A Front End Developer Takes Time 👉 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-Hx2tE19jYn8.html
Basically he is not using protocols at all, difficult to test. He is basically applying basically MVVM with another name, and not making any protocols that conform the VM, thus his code is difficult to test.
I think the author’s efforts in making tutorial videos are helpful for the most part, but going by this video he is completely leading new and inexperienced SwiftUI developers down a rabbit hole filled with frustrations. There’s absolutely no advantage to doing this “pattern” over MVVM. One of the main reasons for these UI patterns is to make it easy to implement automated tests on the code base, but he didn’t even demonstrate how this “pattern” of his makes it easier to test. Meanwhile, why do you use optional/nil parameters for the “UserProfile” struct initializer instead of just using a more idiomatic default initializer/method parameter values? All in all, thank you for making this video but I advise other watchers to be more circumspect with what they “learn” from it.
Thanks for the feedback. I too matured since :) Did you wonder if will AI replace programmers? Check out my take on it 👇 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-9NlECBGI-OM.html&ab_channel=Rebeloper-RebelDeveloper
It is really distracting to watch you look at keyboard every time you type something. Stoping in middle to check what you write and then keep writing. How many years of experience do you have in order not to be able to type without looking at your keyboard?
It's right here: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-fUk9hLLPvqo.html BTW here are 18 Commands That WILL Change The Way You Use Terminal Forever 👉 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-C90lCH-_EBU.html
They do not HAVE to be but it's a good idea. Maybe you're going to use them inside a List... BTW do you want to know why 95% of self-taught developers fail? Find out why here: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-pZaot8RA84g.html
It might work for small projects. But for medium and big projects, with thousands of business rules, it will just fail miserably. MVVM remains the best choice for any iOS project, specially big ones.
Thanks for you input. Do you have experience with medium/big projects? BTW let's create a Sudoku Solver In Swift 👉 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-u7A6mdTq3eU.html
Came here for the comments. Another clickbaity video. MVVM all the way. Don’t respond with a link to another video like you do with all your other replies thanks
MVVM refrained for SwiftUI, I would say :) Next: Make Sure You Always Get the Best Error Alerts! 👇 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-VWgZ99FTuBU.html
The VM approach is also viable for SwiftUI apps, but Apple recommends MVVM as a basis. Find Out How Senior Programmers ACTUALLY Write Code 👉 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-3PlcehlBlS4.html