-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
Routing API revamp RFC #64
Comments
👍 A lot of this is in line with my thoughts on re-vamping routing, perhaps for V8. However, I'd prefer stack semantics for But that's pretty much irrelevant minutia right now. I think the important thing is to take routing in a direction that gives us:
These are difficult problems to solve, and I think we should look for inspiration elsewhere (Prism, MVVMCross etc). |
When revamping navigation, I would also like something like Router.PushDialog. This is a common scenario (I think), when I want edit an item in another ViewModel and then fall back to previous VM with new value. Rigth now I use some hacks like this:
I think that with NavigationStack it would be great to write something like this:
PushDialog would return editVM when Router.Pop would bring us back to CurrentViewModel and handle all edge cases of navigating to terminate returned observable. It's quite easy to make an extension method for that, but if you want to revamp the whole thing either way, it could be just built-in functionality. If there is already a easy way to make it error free, please tell me :) |
Assigning to @RLittlesII I know he's been wanting to get his feet dirty on this type of thing. |
I just started experimenting with routing (UWP app), so while I have fresh eyes, some thoughts:
Rename
RoutingState
toRouter
"Routing state" implies a container of state data rather than a class responsible for navigation actions. "Router" seems a better name for a class that actually handles routing. This is further reinforced by the fact that even on the
IScreen
interface, theRoutingState
property name is "Router". IMO,Router
is both more apt and concise.Formalize navigation stack into a class
Today, we have a handful of commands hanging off
RoutingState
along with a ObservableCollection called "NavigationStack" (note that here it's not even a stack in the data structures sense of the term). It would be better to introduce a new class,NavigationStack
with the following signature:This would leave no ambiguity about what the commands do. If there is value in it, the class can implement ObservableCollection to enable subscribing to notifications.
Router
would then have a read-only property namedNavigationStack
.Replace the Navigate command with method + property
Is there value in Navigate being a command? Writing
router.Navigate.Execute(vm)
feels clunky. Would be better to haveNavigate
be a method, and have a companionNavigating
observable property onRouter
. Another benefit is that the method can have an (optional)bool reset
attribute, thus letting us drop theNavigateAndReset
command onRouter
.The text was updated successfully, but these errors were encountered: