question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reconsider the roles of Router, RouteUtil and RouteRegistry as routes can now be added dynamically

See original GitHub issue

As it is now possible to register routes dynamically to RouteRegistry, we should reconsider the overall design of the router and its concepts. Currently there are several classes with public API for users and those classes might also contain some internal (but public) API. It is not that clear that what is handled by which part. The classes in question:

  • Router
    • getUrl(...) methods which are for application developers to resolve the url for certain navigation target
    • internal static resolve(...) for handling the convention of
      • Main / MainView -> ""
      • AdminView -> "/admin"
    • bunch of internal methods
    • the router is accessed by end user via UI.getCurrent().getRouter()
  • RouteRegistry
    • contains the registered routes, for internal usage
    • currently has the low-level API for adding and removing routes
    • accessed via static methods in SessionRouteRegistry and ApplicationRouteRegistry where former requires the session as a parameter and latter requires servlet context
    • currently accessing and using the registry is quite inconvenient and not meant for application developer facing API
  • RouteUtil
    • only static methods
    • helpers for handling all route related annotations
    • mostly internal usage and inside .internal package, but someone might use these for some reason (?)

The current setup is a bit confusing due to:

  • Router mixing both internal and public API
  • The route registries don’t have all the convenience methods one would expect to find there for registering routes dynamically
  • RouteUtil has another setRoute, setAnnotatedRoute and setNavigationTargets that also allow registering routes to given route registry
  • There should be an easy facade for adding and removing the routes and it is the only thing you should need to know as an application developer, and it should be easily accessible

The current WIP demo and tutorial for registering routes dynamically: https://reviewable.io/reviews/vaadin/flow-and-components-documentation/362#- https://reviewable.io/reviews/vaadin/flow-demo/463#-

EDIT: Also one should consider the future - as in at some point some of the routes might be registered on the client side using Vaadin Router which is its own concept already. Thus we will have Vaadin Router and Flow router separately.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
heruancommented, Dec 19, 2018

I understand, thank you for clarifying. Note that the add-on does not permit to have parameterized router layouts, it just covers an aesthetic aspect of the issue; I hope the official implementation will eventually cover also router layouts (as I described in the other issue, so let’s follow up there).

0reactions
plekucommented, Dec 20, 2018

Added #4890 #4891 #4892 to the V13 scope.

We did consider the parameterized router layouts, and also what it would mean to allow plug-in dynamic route resolvers in addition to our own default route resolver. That is to be continued in #3467 and has to consider that we want to add #2740 too

Read more comments on GitHub >

github_iconTop Results From Across the Web

Set the dynamic routing mode | Cloud Router
When creating or editing a VPC network, you can set the dynamic routing mode to be regional or global. Note: All Cloud Routers...
Read more >
Remove existing routes · Issue #1234 · vuejs/vue-router - GitHub
Right now it is possible to dynamically add routes by calling router.addRoutes([/* routes */]). It would be nice if it was possible to...
Read more >
Configure Protocol Redistribution for Routers - Cisco
This document describes how you can redistribute a routing protocol, connected or static routes, into another dynamic routing protocol.
Read more >
Dynamically Configuring the Angular's Router - Minko Gechev
Dynamically rendering the application's navigation​​ The component above has a single @Input called routes and uses the ROUTER_DIRECTIVES because ...
Read more >
Routers - Spring
Before we get into the specifics of how Spring Integration supports dynamic routing, we need to consider the typical flow of a router:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found