TehShrike / abstract-state-router

Like ui-router, but without all the Angular. The best way to structure a single-page webapp.
http://tehshrike.github.io/state-router-example
294 stars 26 forks source link

Proposal to implement empty state #120

Closed stalkerg closed 6 years ago

stalkerg commented 6 years ago

I really need to have fake states in the route just for grouping pages. Currently, we should implement new state and render page with one uiView tag, it looks too complicated and we should have an extra rending pass. Also, our URL became too long. How I want, example: A.B.C.D - /a/b/d A.B.C.E - /a/b/e but if we will check state to highlight an item in menu A.B.C will be 'active' for both path. C here is the empty state, just for grouping. For .E and .D uiView tag will be from A.B state. In this case, we still have one path for one state but now possible to use different levels in URL and in the state.

In vue-router some part of similar problem solved by named-views - https://router.vuejs.org/en/essentials/named-views.html and other by alias.

TehShrike commented 6 years ago

I do this all the time. Use an empty string for C's route, and a bare-bones pass-through template and you can do whatever other abstract stuff (grouping child states, loading shared dependencies in the resolve function, whatever) for that state.

Does that solve your use case?

stalkerg commented 6 years ago

Does that solve your use case?

probably yes, at least one. The main goal of this proposal it makes this 'empty state' automatically and reuse parent uiView tag.

TehShrike commented 6 years ago

Other than the fact that you need a template that contains just <uiView></uiView>, empty states are already supported as far as I can tell.

stalkerg commented 6 years ago

template that contains just

I suppose we can use parent template.