Swift-MVVMC-Demo icon indicating copy to clipboard operation
Swift-MVVMC-Demo copied to clipboard

How get controllers from a different coordinator ?

Open tsomaev opened this issue 4 years ago • 1 comments

Suppose, I want a presented or pushed the PurchaseController on the FirstCoordinator, and also on the SecondCoordinator I will need a initialize the PurchaseController on the First and Second coordinator ?

@wojciech-kulik I did read your article about MVVM and Coordinator and implemented him on my project, and i like him, thanks 🙂

tsomaev avatar Jul 21 '21 09:07 tsomaev

Yes, it's not a problem, you can instantiate PurchaseController from both coordinators or you can extract this code to another class and pass it as a dependency to your coordinator. However, I think the best approach is to create PurchaseCoordinator and start it as a child coordinator from FirstCoordinator and SecondCoordinator. Most likely you will implement there also some delegate, so you won't duplicate code this way ;)

wojciech-kulik avatar Aug 01 '21 09:08 wojciech-kulik