router properties like params and pathname should be signals
zachlankton opened this issue · comments
Zafar Ansari — Today at 11:44 AM
Route properties like params and pathname should be a signal.
Zach — Today at 11:55 AM
hmm, what are you trying to do? making pathname a signal might be tricky as its tied to navigation and rerendering components
Zafar Ansari — Today at 11:58 AM
Fetch some information when params change or apply an active class on current tag
Zach — Today at 11:59 AM
if the params are changing in the URL this will trigger a rerender of the route/component which is where I'm imagining the fetch is taking place?
or are the params changing in the code like an assignment to a param?
Zafar Ansari — Today at 12:06 PM
We can avoid re-render If only param has changed. I am thinking about a nested route with a user list and selected user details.
Both Vue and Solidjs routers have this feature
Zach — Today at 12:10 PM
gotcha, yeah as long as you are updating the param in code ie $param1 = "newParam" this should be totally doable... but if a nav happens otherwise (clicking back) this gets tricky
I can see doing this for route parameters, but not sure I can do this for pathname yet
Zafar Ansari — Today at 12:20 PM
How can we apply a CSS class on active links If pathname is not reactive?
Zach — Today at 12:21 PM
at the moment, because all of this requires a rerender, it would just work to check the pathname and set the class, but I know that's not what you are looking for
I need to look into how to do this