-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Who should be responsible for building a ViewController? #14
Comments
Would love to hear your thoughts on why it was implemented this way 😄 |
Hi @AndrewSB, One of the principles behind Cordux is that view controllers don't need to know about it. You'll notice that |
That makes a lot of sense! I like how it reduces complexity for the viewControllers. But on the other hand, I don't like that the responsibility of viewController initialization & injection is given to the coordinator. Thinking out loud now:
what do you think of handing the responsibility of creating the viewController into a sub-object, a |
Hi @AndrewSB, I do agree that the common lines of injecting the coordinator as a handler and then setting a view controller's In my opinion, the coordinator is ultimately responsible for view controller creation, even if it chooses to delegate that responsibility to a builder object. Or even if it did so via a class level My main concern is simplifying controller management; factory methods or builder objects are a valid choice for projects — I wouldn't say no to them! — but both seem only to move around but not simplify the total complexity of injecting a handler and setting up and assigning a context. |
From what I see, the coordinator is in charge of
init
ing the viewController, injecting itself as its handler, and setting it's corduxContext.Example
ForgotPasswordViewController
:Why not instead choose to make the viewController responsible for it's own creation? Factory function style:
There could even be a default implementation of this function, from same BaseVC, or protocol conformance of the viewController, so a client of the library wouldn't have to remember to create the VC, and then inject a coordinator & context.
The text was updated successfully, but these errors were encountered: