Replies: 9 comments
-
I believe rewriting the router to fit your idea has been discussed and hopefully is an aim for v3. Mithril desperately needs nestable routing imho EDIT: Fixed a horrendous typo |
Beta Was this translation helpful? Give feedback.
-
@andershol -- not sure if it addresses your specific issue, but you can manage page transitions at the layout level. see this gitter message for link to flems example. re:
here's your flems augmented |
Beta Was this translation helpful? Give feedback.
-
Thanks for the pointer. I tried to simplify it a bit (to use css-transitions, and when it is assumed that there will be exactly one TransitionLayout on each page by only handling a single outbound/inbound and by starting slide in oncreate, you don't need to hook into the mithril resolveRoute, but can just update stack and check for direction in oncreate).
So what you are saying is that the diff-algorithm handles the individual elements inside a route-resolver, but not inside a component. Thanks for pointing that out. I had not payed attention to that distinction, although in hindsight I guess I used that in another project. |
Beta Was this translation helpful? Give feedback.
-
We are currently looking into this. #2281 is closed, but that's the general direction we've been looking. (Currently, our route resolvers haven't been paying off super well.) Full component-driven routing is unlikely to occur until we get React-like context (#2148), but this is a space we've been exploring. |
Beta Was this translation helpful? Give feedback.
-
Would you happen to have a status on where you’re at with “looking into this”? |
Beta Was this translation helpful? Give feedback.
-
There's #2281 (closed for other reasons), but the current state of my design work is here. There's no official timeline, but there's two main blockers:
|
Beta Was this translation helpful? Give feedback.
-
@isiahmeadows Thanks for pointing to this. It was an interesting read. Although, for someone being less theoretical in their thinking, it would be beneficial to have some sudo code along with the API to see how code might look using that API. |
Beta Was this translation helpful? Give feedback.
-
@kczx3 Here's a couple small concrete examples: 1, 2 Neither are actually runnable - they're just examples. |
Beta Was this translation helpful? Give feedback.
-
Thank you! |
Beta Was this translation helpful? Give feedback.
-
Is this something you're interested in implementing yourself? No
Description
This is just a rough idea. Maybe it would be useful to instead of writing
m.route(document.body, "/page1", { "/page1": Page1 });
to be able to write something like:
m.mount(document.body, { view: () => m(Router, { default: '/page1', routes: { "/page1": Page1 } }) });
such that routing could be done inside layouts and not only at the top level. It might also allow routing to be split into components and nested.
A larger sample (the implementation is a quick hack), tested in Firefox and chrome:
Why
Sample 3 is my motivation. It seems to me that I in this case want to not have the routing on the top level, but instead inside the layout.
Some of the motivation is that it seems that the diff-algorithm will not (refer to sample 1) match up the Layout component used in Page1 to the Layout component used in Page2, so the Layout is not updated, but removed and replaced, making animation of the content imposible.
Open Questions
It seems the implementation could be made less hackish if there was a onafterview method, that was called after all child view methods had been called, or if the view method for the child components was called by the m-method (i.e. so the view methods for the child components was called and completed inside the parent view method).
The use of target:'_Self' is a hack (that at least work in Firefox and Chrome) to have m.route.Link use the href and not its own onclick as the onclick use a new value for m.route.prefix, not the one used to set href.
Beta Was this translation helpful? Give feedback.
All reactions