Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Controller is held by Router? #17

Open
jeffery812 opened this issue Feb 6, 2018 · 1 comment
Open

Controller is held by Router? #17

jeffery812 opened this issue Feb 6, 2018 · 1 comment

Comments

@jeffery812
Copy link

In my understanding, the Router should hold Presenter only, not Controller.

But in your VIPER framework, the controller is held by Router.

class LoginRouter: LoginWireframeProtocol {
    
    weak var viewController: UIViewController?
    
    static func createModule() -> UIViewController {
        // Change to get view from storyboard if not using progammatic UI
        let view = LoginViewController(nibName: nil, bundle: nil)
        let interactor = LoginInteractor()
        let router = LoginRouter()
        let presenter = LoginPresenter(interface: view, interactor: interactor, router: router)
        
        view.presenter = presenter
        interactor.presenter = presenter
        router.viewController = view
        
        return view
    }
}
@SergeyPetrachkov
Copy link

another approach is to have Router methods signatures like :

func showMyModule(from view: UIViewController, moduleOut: ModuleOutParameters)

and pass view from presenter.

Moreover, Router should not be responsible for creating and setting up modules. It's Assembly layer responsibility. Each modue should have Assembly that handles dependency injections and stuff.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants