You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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.
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
The text was updated successfully, but these errors were encountered:
rpassis
changed the title
Reusing view controllers in different contexts
Reusing coordinators & view controllers in different contexts
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:
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.
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
The text was updated successfully, but these errors were encountered: