Skip to content
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

Reusing coordinators & view controllers in different contexts #9

Open
rpassis opened this issue Aug 16, 2018 · 0 comments
Open

Reusing coordinators & view controllers in different contexts #9

rpassis opened this issue Aug 16, 2018 · 0 comments

Comments

@rpassis
Copy link

rpassis commented Aug 16, 2018

Hi Arthur,

I came across this repo and accompanying blog post when doing some research on different coordinator + MVVM approaches.

Our team uses our own flavour of coordinators and we are generally happy with how everything works however we've been running into some reusability issues that I was hoping you may have some ideas to work around that.

To use this very repo as an example, it works great when we assume that the RepositoryListCoordinator is the start up screen of the app.

Assuming a more complex application, there may be scenarios where you'd like to start this feature from a different entry point in the app. As an example, I maybe looking at a screen with a button that says "show repository list". The button action will ultimately trigger a coordinate(to:) call to start this coordinator.

In this case it is not possible to reuse the coordinator (because it expects a UIWindow in its initializer), nor the view controller because:

  1. If we push it into an existing navigation controller, tapping on the back button will leak the coordinator because we are not listening to that touch specifically.

  2. If we do assume that there will be a back button that we can capture and remove the coordinator correctly (like you do in the LanguagesListViewController), we are now left with a view controller that assumes it will always be "pushed" into a nav controller, and that it will always have a back button. What if I wanted it to be the root view controller of a navigation controller? Or perhaps present it modally instead of via push?

Have you run into any these issues and do you have any thoughts and ideas on how to solve them? Currently we "inject" these buttons from the navigator that calls the next navigator (by exposing the target view controller) but it feels very manual, prone to error and not very elegant.

I look forward to hearing your thoughts and experiences with this.

Thanks!
Rog

@rpassis rpassis changed the title Reusing view controllers in different contexts Reusing coordinators & view controllers in different contexts Aug 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant