MVVM Combine Swift (2022) | UIKit | Transform Input & Output

  Переглядів 10,613

Kelvin Fok

Kelvin Fok

Рік тому

In this video, we structure a simple Quote app using MVVM architecture with combine framework using an Input & Output enum which succinctly defines the communication between the View Controller and the View Model.
Source file - github.com/kelvinfok/mvvm-com...
Master the skills to become a senior iOS developer
➡️ www.udemy.com/course/ios-swif...
Build a Swift Package Manager library
➡️ www.udemy.com/course/ios-15-s...
Build a finance stocks app
➡️ www.udemy.com/course/ios-14-s...
Build a ToDoList app with Firebase
➡️ www.udemy.com/course/build-a-...
Send emails inApp with Sendgrid API
➡️ www.udemy.com/course/ios-13-s...
Build a weather app with Alamofire 5 and REST API
➡️ www.udemy.com/course/ios-13-s...
Build onboarding flows with Lottie animations
➡️ www.udemy.com/course/ios-swif...
Build a basic onboarding flow for beginners
➡️ www.udemy.com/course/ios-swif...

КОМЕНТАРІ: 50
@sonamsodani3272
@sonamsodani3272 25 днів тому
Well Explained and easy to understand. Thank you for making this tutorial.
@reece5863
@reece5863 Рік тому
Went through a bunch of combine mvvm videos and none were what I was looking for. EXCEPT THIS. Thanks Kelvin.
@kelvinfok
@kelvinfok Рік тому
Glad it helped! Share this to someone who might need to watch this too 😀
@user-bj8yc5vh3m
@user-bj8yc5vh3m Рік тому
The most useful MVVM tutorial I have seen on the internet I really appreciate it thank you so much.
@kelvinfok
@kelvinfok Рік тому
Thanks for the kind words! Let me know what other content you would like to see.
@matthewdolan720
@matthewdolan720 Рік тому
Great video, Kelvin! Very detailed and well-explained! Thank you!
@adammitchell8472
@adammitchell8472 Рік тому
Man, I've been scratching my head trying to figure out mvvm with uikit, you've presented this pretty durn elegantly. Very nice.
@kelvinfok
@kelvinfok Рік тому
Glad it helped!
@ajaybabusingineedi5797
@ajaybabusingineedi5797 Рік тому
Nice explanation. I like the brevity of the demo.
@akinji27
@akinji27 2 місяці тому
I laughed a lot and I learned a lot. Great tutorial thank you!!
@abanoubashraf1308
@abanoubashraf1308 Рік тому
bro your videos are on fire, thanks a lot and keep it up
@kelvinfok
@kelvinfok Рік тому
Glad you found it helpful!
@azhmanadam9786
@azhmanadam9786 10 місяців тому
Amazing conten. Thanks a lot
@danylokurylo3142
@danylokurylo3142 Рік тому
Great video, love the energy!
@kelvinfok
@kelvinfok Рік тому
Thanks glad you found it helpful
@kodekarim
@kodekarim 11 місяців тому
this video on Combine and MVVM is absolutely incredible! The level of detail and explanation provided is outstanding. I truly appreciate the effort put into creating such a valuable resource for developers like me. Thank you for sharing your expertise and helping us dive deeper into these important concepts. Kudos to you! 👏🎥💡
@kelvinfok
@kelvinfok 10 місяців тому
Glad it helped!
@NikolaPrljeta
@NikolaPrljeta Рік тому
I was struggling with DI quite a bit before this video. This cleared everything up. Thanks a bunch! 👌🏻
@kelvinfok
@kelvinfok Рік тому
Glad you found it helpful!
@Hordaric
@Hordaric Рік тому
Good stuff!❤
@kelvinfok
@kelvinfok Рік тому
Glad it helped!
@jsmnp07
@jsmnp07 Рік тому
I like your videos on Combine and MVVM ... Hope many more to come🙂
@kelvinfok
@kelvinfok Рік тому
Glad it helped! 😀
@pradeepkumar-tm5et
@pradeepkumar-tm5et Рік тому
So far this is best approach for combine with UIKit. Please post more videos. Thank you for your valuable time.👍
@kelvinfok
@kelvinfok Рік тому
Glad you found it useful!
@vishalbhai123
@vishalbhai123 Рік тому
Very nice and precise explanation, Thanks a lot 🙂
@kelvinfok
@kelvinfok Рік тому
Glad it helped!
@vishalbhai123
@vishalbhai123 Рік тому
@@kelvinfok Which one is better Future or AnyPublisher for API Client method? Please give a bit overview If possible.
@Iwasee
@Iwasee 6 місяців тому
Thanks a lot, I like this pattern and your tutorial was really great
@Rahul-jf5kf
@Rahul-jf5kf 3 місяці тому
great work Kelvin, can you make same app in SwiftUI, How to do binding from view to ViewModel
@tomaszkubiak1011
@tomaszkubiak1011 Рік тому
Hi! Great tutorial, really helped me figure out how to use MVVM + combine with UIKit based application. One question regarding the differences between bind() and handleGetRandomQuote() . Bind is called only once and it creates a subscriber to vm.transform output. HandleGetRandomQuote create a sub to serviceType every time and when it completes it removes itself from cancelable set and that's why you create a new sub every time you call handle function? What is the advantage/disadvantage/reason to create a new subscriber every time? Is it because the getRandomQuote returns a publisher, so it all the time cycles through new publishers and subscribers?
@JohannFong
@JohannFong Рік тому
Hey Kelvin! great stuff! for MVVM I'm usually thinking about the view-model as an orchestrator for binding the view to a model/display-model/ui-model. In this particular way you have implemented I guess the 'model' in MVVM would be the data you are passing back through the output enum as a associated value?
@kelvinfok
@kelvinfok Рік тому
Hi Johann, that is correct. I reckon there are many variations to the MVVM depending on the number of layers of separations. Previously I worked with Uber RIBS, which is like VIPER and it has 5 layers of separation. Also note that more separation increases readability & testability but also increases compile time.
@Rahul-jf5kf
@Rahul-jf5kf Рік тому
Hi Kelvin, Nice Video👍. thanks for creating project from Scratch. One Doubt Do we need to pass input from Controller as mentioned in bind method? cann't we mention any observer so that values will reflect in VM
@kelvinfok
@kelvinfok Рік тому
hi Rahul, I don't fully understand your question. But there are many variations to this. Some of my peers do not prefer this approach and prefer to pass in observables instead. Personally I think this style mentioned in the video makes debugging easy.
@Rahul-jf5kf
@Rahul-jf5kf Рік тому
can you make Combine tutorial on, an Model with fields username and password lets say LoginRequest and on successful completion it returns PurchaseListModel, which is a list. in short i want request type as model and response type as List of Models. and is it possible that controller does not hold reference to request model as well as response model, they should be in VM only also binding of View and Model with VM
@anthneyjane1097
@anthneyjane1097 Рік тому
Do you think this will catch on with the greater swift community? The end result is beautiful but I think you sacrifice initial readability. I love the combine framework, but even for me it took a while to wrap my head around what was going in the code at the start. I wonder how much this differs with SwiftUI, since you want to limit all UI logic to the view. Keep up the great work, I love your videos since not a lot of channels prioritize doing tests and dependency injection.
@kelvinfok
@kelvinfok Рік тому
I don’t think it will catch on with the greater swift community because there are many variants to the MVVM. Yup I agree that initial readability is a concern and the beauty is in its succinct input and output. A great resource to check out is essentialdeveloper. I leant a lot from those guys. 😀 As for SwiftUI, I cannot comment much as I don’t have extensive experience with it.
@anthneyjane1097
@anthneyjane1097 Рік тому
​@@kelvinfok Yeah I love the guys at essentialdeveloper. I watch their videos to humble myself, because I realize there are still areas of swift that I haven't explored much of. Apple not making any updates to the Combine framework also speaks volume, and when apple 'speaks' the community listens. I think Apple's plan is to slowly depart from Combine and and completely replace it with async/await.
@rohitp9371
@rohitp9371 Рік тому
Why you used AnyPublisher in QuoteService and PassthroughSubject in ViewModel and ViewController?
@kelvinfok
@kelvinfok Рік тому
hi Rohit, AnyPublisher is typically used as a readOnly, so it cannot modify the stream. On the VC & VM, we typically use a CurrentValueSubject or PassthroughSubject to receive events, but always output as a AnyPublisher. For instance, the VM will receive an AnyPublisher from the VC, because the VM shouldn't have write access to the VC's stream. And vice versa.
@vaitkeviciusegis
@vaitkeviciusegis Рік тому
I really liked it, although isn't this an example of 'God's VC' where everything is in one Vc ? By the way, do you think for beginner it's useful to copy/paste everything without understanding too much ? I feel that there is no other way to start.
@kelvinfok
@kelvinfok Рік тому
Sorry I don’t understand the part about God’s VC since the view model separates the business logic. I won’t suggest any copy pasting. In fact, it’s better to understand a little of something fully, and gradually increase the scope. For starters it can be helpful to start small. For example, on viewDidLoad set the view backgroundColor to .red. Start by separating the VM from the VC, create the binding and write a unit test.
@vaitkeviciusegis
@vaitkeviciusegis Рік тому
@@kelvinfok God's vc is a viewcontroller that does everything ..? Just picked up one of yours udemy class, goal is to understand crud/closures/delegates, seems to be hardest but most important things at least at this stage of my journey.
@roh9934
@roh9934 Рік тому
why use anipublisher when we can do the same thing with Future easily?
@kelvinfok
@kelvinfok Рік тому
Yup, Future is definitely possible.
@redditrecaps8925
@redditrecaps8925 Рік тому
Kelvin if I could kiss you I would. Please never stop making content
@kelvinfok
@kelvinfok Рік тому
Thanks for the encouragement. I was about to stop making videos Cus I didn’t think people were watching and the channel wasn’t growing as per expectations.
@user-yd9xy3rb4x
@user-yd9xy3rb4x Рік тому
Have you ever tryed to separate vm and controller to different files and use DI? Man, not good.
@kelvinfok
@kelvinfok Рік тому
Yes I have. You can check out my other MVVM videos. I left it in the same file just for convenience when teaching. In a real production, they are separated.
Getting started with Combine + UIKit in Swift
23:45
Swift Arcade
Переглядів 17 тис.
Эффект Карбонаро и пончики
01:01
История одного вокалиста
Переглядів 8 млн
🔥 Україна виходить у ФІНАЛ ЄВРОБАЧЕННЯ-2024! Реакція alyona alyona та Jerry Heil #eurovision2024
00:10
Євробачення Україна | Eurovision Ukraine official
Переглядів 324 тис.
Protocol Oriented Programming (Swift 5) MVVM & Unit Test
48:00
Kelvin Fok
Переглядів 7 тис.
Теория MVVM
10:46
SwiftBook
Переглядів 32 тис.
NEW GPT-4o: My Mind is Blown.
6:28
Joshua Chang
Переглядів 62 тис.
OpenAI’s GPT-4o: The Best AI Is Now Free!
9:14
Two Minute Papers
Переглядів 31 тис.
Getting started with iOS modularization by Luka Terzić
23:48
Infinum
Переглядів 3,4 тис.
Master The Combine Framework: From Beginner to Advanced
1:32:13
tundsdev
Переглядів 36 тис.
Bamboo Creations with 3 arrow #bamboo #Slingshots #DIY
0:14
Bamboo Art
Переглядів 112 млн
Bamboo Creations with 3 arrow #bamboo #Slingshots #DIY
0:14
Bamboo Art
Переглядів 112 млн
Press tutorial😮‍💨✅
0:26
Jamshid Jamshid
Переглядів 14 млн