Substate routing RFC - #40
jonathanKingston wants to merge 1 commit into
Conversation
|
would Components with enhanced async handling, act as one of these substates? |
|
@stefanpenner that wasn't really the intention no, I'm not really seeing how that would fit into the mix however I'm open to building that in certainly. Unless of course you mean things like wizard style interfaces, which certainly would be a use-case. The main use-case is for pages within pages, mostly modals where businesses change their mind on it's usage and large amounts of code needs to be refactored for something that to a product owner looks a small change. |
|
Cc @ef4 We chatted about this problem briefly |
|
@stefanpenner is that the direction you were thinking for components question? |
|
I dont like the idea of reserving a URL, I think it could create a lot of confusion for something that may never happened and we are trying to avoid in the first place. Seems more like an edge case. |
|
@MiguelMadero you are probably right, I just thought it covered my use where by the page could be converted at any point. |
|
@jonathanKingston sorry, I didn't mean to sounds like your use case wasn't important. You stated the reasons in the RFC. I was just trying to balance how easy it's to learn something another concept vs the value it would bring based on the probability of that being needed. Overall I like the idea behind the RFC. Another way of achieving something similar is by using nested-routers. Using login as an example, you could have all of the login flow handled by a different router. This different router would use a different location strategy (e.g. instead of history/hash it could use |
|
@MiguelMadero that is fine, it can always be added later if it was needed anyway. If multiple substates were used at once the data would need to be stored outside the global areas currently used to store state (query string, url path and hash), as it would cause data to leak into the other routes if they are used. This would setup the following sub state routes:
My only worry with this is persisting state on page refresh:
The problem I think with the nested routers solution is the complexity of setup (Which could potentially be resolved with several conventions however). |
|
@jonathanKingston the issue with persisting state or not could be resolved based on how do we configure the router. For cases where we don't need to persist the state we could simply set the location to none: However, I'm proposing we create 2 different location types to better support persisting state without conflicting with the main router. One of them is to persist to localStorage. The data would look like this: An alternative approach is to simply use the query string, but encoding the values in a way that doesn't conflict with other routers, for example:
I agree. It's too early and simply a POC. I think all of that could be simplified with conventions and better naming. I like your suggestion of using |
|
After reviewing this in depth with the core team, we feel like this doesn't quite pass the bar in terms of unlocking new functionality at the cost of the complexity that it adds. In particular, we feel that with the introduction of the We would love it if you could try to solve the problems that motivated this RFC using that approach, and open issues with use cases that you aren't able to achieve. |
|
The However the main rationale for this RFC was the ability to create standard links to a specific substate so that an application can provide clean separation to the substate such that it could turn into a normal route if it needed to in future. The best implementation I feel would be available for the computed property solution would likely pollute the application namespace (assuming the substate was global) via a mixin perhaps. Personally I don't think this could scale if I worked at a company which required lots of these (I used to, but not currently). For me the isolation of the modal into a route of its own whilst still on the same route that triggered the modal is the only way I can think of to make this scale. |
|
@jonathanKingston One thing I don't understand—how do you "create standard links" but not modify the URL (per the introductory sentence of your RFC)? |
|
@tomdale standard template link, such that a developer and template author doesn't need to know the implementation so much. |
Rendered