Closed mcousillas6 closed 5 years ago
What do you recommend to handle the case when we need to navigate to a certain UIViewController but the view model/params changes?
How about overloading with optional params ?
Looks great! What do you recommend to handle the case when we need to navigate to a certain
UIViewController
but the view model/params changes?
To pass parameters, the best approach is to put them as parameters on your Route, if you are using enums like I did you end up with routes like .login(username: String, password: String)
then, you can use that to initialize your viewModel & views properly.
Updated with some improvements:
transitionConfigurator
callback for Routes, so you can set transitionDelegates and so on.currentViewController
works, so it keeps in sync with the actual navigation hierarchy.Looks great! What do you recommend to handle the case when we need to navigate to a certain
UIViewController
but the view model/params changes?To pass parameters, the best approach is to put them as parameters on your Route, if you are using enums like I did you end up with routes like
.login(username: String, password: String)
then, you can use that to initialize your viewModel & views properly.
Do you thing that creating two different routes for the same view but responding to different view models would be a better approach?
Looks great! What do you recommend to handle the case when we need to navigate to a certain
UIViewController
but the view model/params changes?To pass parameters, the best approach is to put them as parameters on your Route, if you are using enums like I did you end up with routes like
.login(username: String, password: String)
then, you can use that to initialize your viewModel & views properly.Do you thing that creating two different routes for the same view but responding to different view models would be a better approach?
Why would you have 2 view models for the same view? š¤ Normally, Views and VMs have a 1 to 1 relation, with the VM defining the business behaviour.
Either way, If you really need different VMs, yes, having two separate routes is better. I would still go for the parameter approach if you only need to inject some property value, for example, if you have a VM that receives an ID to fetch a profile or similar.
Looks great! What do you recommend to handle the case when we need to navigate to a certain
UIViewController
but the view model/params changes?To pass parameters, the best approach is to put them as parameters on your Route, if you are using enums like I did you end up with routes like
.login(username: String, password: String)
then, you can use that to initialize your viewModel & views properly.Do you thing that creating two different routes for the same view but responding to different view models would be a better approach?
Why would you have 2 view models for the same view? š¤ Normally, Views and VMs have a 1 to 1 relation, with the VM defining the business behaviour.
Either way, If you really need different VMs, yes, having two separate routes is better. I would still go for the parameter approach if you only need to inject some property value, for example, if you have a VM that receives an ID to fetch a profile or similar.
I meant a view that can be presented in different scenarios using different view models and/or parametes. I think in that case two routes is better to avoid conditionals and extra logic in the same Route case.
Looks great! What do you recommend to handle the case when we need to navigate to a certain
UIViewController
but the view model/params changes?To pass parameters, the best approach is to put them as parameters on your Route, if you are using enums like I did you end up with routes like
.login(username: String, password: String)
then, you can use that to initialize your viewModel & views properly.Do you thing that creating two different routes for the same view but responding to different view models would be a better approach?
Why would you have 2 view models for the same view? š¤ Normally, Views and VMs have a 1 to 1 relation, with the VM defining the business behaviour. Either way, If you really need different VMs, yes, having two separate routes is better. I would still go for the parameter approach if you only need to inject some property value, for example, if you have a VM that receives an ID to fetch a profile or similar.
I meant a view that can be presented in different scenarios using different view models and/or parametes. I think in that case two routes is better to avoid conditionals and extra logic in the same Route case.
Oh okay! yes, in that case it's way more clear to have two routes.
Looks great! :clap:
Description:
Advantages
Imeplementation details
Navigator.swift
file, which implements the base behavior for a Navigation.Route
protocol defines a basic interface to create a UIViewController, yourRoutes
are the ones in charge of Creating the UIViewController instance and wire it up with it's corresponding viewModel. CheckOnboardingRoutes
orHomeRoutes
for examples.AppNavigator
that manages your root navigation stack for your app and then you could have extra navigator for other flows such as a modal flow that is isolated, or one for each tab on a tabViewController.