Swift Tutorial: How to use Coordinator Pattern with MVVM - Advanced Navigation in UIKit & SwiftUI

Swift Tutorial: How to use Coordinator Pattern with MVVM - Advanced Navigation in UIKit & SwiftUI

Karin Prater

2 года назад

38,371 Просмотров

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


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

pheonix1371
pheonix1371 - 03.07.2023 10:24

Thanks this was really useful.

Ответить
Abraham González
Abraham González - 29.05.2023 23:50

Hey! Karin, ,I just discovered your channel and you have really great content, you are a great teacher, i learned a lot with this video. Thanks for sharing your knowledge!

Ответить
Adam Zuspan
Adam Zuspan - 28.05.2023 01:25

Amazing content always using swift best practices along with great explanations and absolute understanding!!! Thank you!!!!

Ответить
Abel Demoz
Abel Demoz - 22.05.2023 15:49

Great video. Coordinators with Combine and MVVM are really powerful. Another approach would be to construct coordinators using factories, and delegate the responsibilities of navigation (e.g. pushing and popping) to a navigator class which gets injected into coordinators as a dependency.

Ответить
HashCat
HashCat - 07.05.2023 18:02

Will there be a video on ELM architecture ?

Ответить
Alex Sal
Alex Sal - 02.05.2023 07:41

Amazing video, it's so well explained and helped me a lot to learn how to implement the coordinator pattern for navigation. Thank you so much ! :D

Ответить
Kazakov
Kazakov - 13.03.2023 19:41

can someone please explain me how to transfer "hasSeenOnboarding" boolean state?

i don't understand one thing :

so in appCoordinator we create method which listen for the current state and depends on it load different flows: -
1.if user launch application for the first time it's goes up for "onboarding" flow...okay but how do actually we change the state of it while user end up looking for onboarding instructions?

I understand that Karin created observable object on appCoordinator, but which trigger change the state? She just pass this property inside " OnboardingCoordinator init() " And in start method simply put true inside this object.

where we add target or some action on done button of OnboardingView?

Ответить
Rushi Bhatt
Rushi Bhatt - 25.02.2023 01:14

Great video Karin.. thank you for explaining the approach. Here instead of closers, isn't it better to just inject these coordinators inside the viewModels and then have those viewModels be injected in ViewControllers or Views. That way, from view or viewModel, we can directly call any methods on coordinators if need be,

Ответить
Gabriel Andrade
Gabriel Andrade - 08.12.2022 00:16

Awesome video! There is only one thing that I don't really understand, why are we storing references to the child coordinators in the parent coordinator class ?

Ответить
Amerikkalainen
Amerikkalainen - 25.10.2022 20:04

This was fantastic - thanks!

Ответить
JimGDawg
JimGDawg - 16.10.2022 05:05

I really like your approach. The only downside (and its pretty big) is you lose custom environment injection in SwiftUI (either custom environment keys, or environment objects). So I guess in your approach, you would hoist that data to a shared state singleton or thread it through the view hierarchy? I dont like either of those solutions, but I dislike SwiftUI navigation more : D

Sidenote: really great stuff on your channel. I'm getting a lot out of it, especially as a UIKit dev coming to SwiftUI.

Ответить
Если что, я дома
Если что, я дома - 11.10.2022 06:03

Oh my gosh. Your video is brilliant. I like it a lot. I just started coding and after this video I am definitely clear with Coordinator pattern. By the way use SWIFTUI with UIKIT is a brilliant idea.Thank you very much for this content. Like and subscribe.❤

Ответить
vebbis
vebbis - 11.09.2022 14:12

Precisely what I was looking for. The use of Combine fits well if you are listing to the Auth state and want to use coordinators.

Ответить
okarm
okarm - 01.08.2022 17:01

Brilliant content. I'm an old Android dev who is branching off into iOS (Kotlin Multiplatform) and this is invaluable. I have been hearing about "Coordinator" for years but never looked into it. I thought it was some esoteric abstract way to compose application flows.

But it's literally the same pattern as our Fragment-based navigation, where Coordinator fulfills the same role as a Fragment! We have been using this for years in Android apps! Except we get this for "free" from Google as a part of their AndroidX library suite. This makes the switch all the more easy.

Ответить
Kleczkovsky2r
Kleczkovsky2r - 27.06.2022 20:22

S tier content! :D

Ответить
Daniyal
Daniyal - 20.05.2022 14:13

Hi @karin Hope you are fine. Which one is better coordinator pattern or SwiftUi navigation which you showed in the last tutorial?

Ответить
Scott Wilson-Billing
Scott Wilson-Billing - 07.05.2022 00:11

That was great thanks! We have been seeing inconsistencies with SwiftUI navigation in our Kotlin Multiplatform Application, which we finally solved using the Decompose library.

Ответить
Leandro Lopes
Leandro Lopes - 04.05.2022 04:04

Valeu!

Ответить
K S
K S - 03.05.2022 15:14

thank you for the video. deinit coordinator is too difficult, so i choose viper router to handle the navigation...

Ответить
Jace Crawford
Jace Crawford - 02.05.2022 00:14

I can't believe more and more people don't reverse migrate back to UIKit. My time with swiftui was abysmal. I feel like it is still some time away from the standard for large projects

Ответить
Cong Le
Cong Le - 01.05.2022 02:59

This might be a rare scenerio (and just a suggestion): can you add Objective-C view controller into this current structure, aka MVVM+C with SwiftUI View controller, UIKit View Controller, and Objective-C view controller? Some old project might be in the migration phrase and it does not tranalate its codebase to the Swift or SwiftUI fast enough.

Ответить
Cong Le
Cong Le - 01.05.2022 02:55

Thanks for this imformative tutorial! Keep up with the good work, please!!!! ❤️

Ответить
ekucet
ekucet - 29.04.2022 11:21

yes, it is awesome video tutorial. Thank you for sharing your experiences.

Ответить
Michael K
Michael K - 28.04.2022 15:44

I just came over to a team that is in the process of planning to migrate their app to SwiftUI and Combine. Thanks for this! I'm still learning Swift (I have a C, Python and Kotlin background, so it's relatively familiar to me), but this is pretty close to a "middle-ground" for our current app and a full SwiftUI+Combine backend.

Ответить
yerih iturriago
yerih iturriago - 28.04.2022 03:41

Do you have tutorials for sales?

Ответить
Dima Sai
Dima Sai - 26.04.2022 16:16

I guess better use Coordinators on Swift UI based

Ответить
Otniel
Otniel - 26.04.2022 12:10

thankyou, great tutorial

Ответить
Alexander Karaatanasov
Alexander Karaatanasov - 25.04.2022 21:53

This is beautiful! Just the way I would use SwiftUI and UIKit together. I think SwiftUI navigation really sucks and this is a great way to have "imperative" navigation while also making it declarative and reactive using Combine. I also like how these coordinators not only abstract away the navigation, but also handle data flow and act in a way as a "view factory". Fantastic concept presented in the best way possible. Also I really like the example you showed in the video - it's both simple enough to not overwehlm the viewer and complex enough to show off the concept properly and also see the benefits of having unidirectional dataflow. Fantastic! Keep up the good work!

Ответить
Filipe Nobrega
Filipe Nobrega - 25.04.2022 09:50

Nice video, I had to do something similar in my project, I like swiftUI a lot due to the speed up that it gives, but some bugs is very annoying, other than that I see a lot of performance issues with SwiftUI as well, my solution was to use UIKit for top level on everything, this also avoid some random redraws

Ответить
Steve Miller
Steve Miller - 24.04.2022 17:27

On the one hand this is a great way to get rid of the dependencies between views that NavigationLink creates by requiring an opaque type and get the navigation out of the VC...on the other hand it's going to huge pain in the ass if Swift projects are going to need UIKit navigation and SwiftUI views for the foreseeable future...

Ответить
Chris Hornberger
Chris Hornberger - 24.04.2022 14:17

Can you put up a link or show your code on your navigation that causes that second draw/navigate at the beginning (right side)? The only time I ever see that is when I break the basics of state updates, usually because I've made a horrible mistake in timing or nav-time updates to state. I'm just not sure how you got that to be a thing.

Ответить
McKinney Travels
McKinney Travels - 23.04.2022 22:44

Nice tutorial on using coordinators, combine, and view models in UIKit with a bit of SwiftUI. Also I like the explanation of benefits of using Coordinator pattern (an ViewModels). I"ve used these patterns about three years ago in a commercial App (all UKit). What's your thoughts of using coordinators in a pure SwiftUI app (no UKIt)? Something I've just started to think about. Do you think the major issue is navigation?

Ответить
Steve Miller
Steve Miller - 23.04.2022 21:00

This is a really interesting use of combine, but it seems like it would be much better to have the orientation flow as a modal under the navigation controller

Ответить
Deepu Daa
Deepu Daa - 23.04.2022 14:16

Hey very helpful content as always 👌👌, can you please make a video on navigation between Swift Packages views using TCA.

Ответить
Camilo Vargas
Camilo Vargas - 23.04.2022 13:10

Thanks! I am just starting to learn Swift and this is incredibly useful.

Ответить
MistyMu
MistyMu - 23.04.2022 11:57

I have noticed a few bugs (some show-stopping) with SwiftUI navigation that would be inconsistent between iOS versions on the app I am working on. I also had to go back to using UIKit behind the scenes for navigation. This is definitely a more elegant solution than what I am currently using.

Ответить
Borja Rodriguez
Borja Rodriguez - 23.04.2022 10:12

Thanks Karin for good content

Ответить
Guitaripod
Guitaripod - 23.04.2022 08:37

Thanks. It was interesting to see a different method of achieving a clear separation of concerns in SwiftUI 👍 Combine ftw

Would you please consider using dark mode in the future? I'm watching these on a big screen, and light mode burns my eyes :D

Ответить