-
-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggestion: Allow reacting to search params and fragment changes on the client side #509
Comments
I'm almost finished with migrating my site to v3 from v2, and found this exact issue is the most punishing one. Client-side routing using query parameters or fragments have not-so-insignificant use-cases IMO, and should be definitely supported.
Currently (elm-pages 10.2.0) query params or fragments CAN be read and used in Route modules' BTW, for now I'm patching my site so that links with query params or fragments to have accompanying |
Yes I think it's just an oversight @ymtszw. I think |
@dillonkearns That sounds okay, but is there any thought behind not triggering |
I'm not following, could you elaborate on what you mean there? I don't see any reason that
Elm SPAs don't have a built in concept of a Route, so not sure what you mean here? |
What I mean is, in bare Elm SPA or elm-pages v2 app, simply putting |
No I'm still not following. Are you talking about creating links, or handling URL changes? #479 is about creating links, not responding to links. You can manually create links easily without the built-in type-safe helpers, you just need to add the low-level |
The issue on creating links (#479) is auxilliary, just for convenience. In v3 currently, if we put the internal links but if that URL does not alter "path" part (i.e. targeting Route) from the URL where the user currently is, there are no way to capture the URL change. This is the issue that OP describes. And I BELIEVE this can be achieved without adding additional API ( |
I don't think think the semantics of calling |
That sounds reasonable I see 👍 In my personal cases I had mostly implemented my |
Even if they're re-run tolerant, it would be surprising to have init Effect's re-running on every URL change, especially if you are rapidly changing them. For example, if you change them on every keystroke. So it would break some use cases in an unsolvable way. Whereas |
Some way to react within the route itself to changes in the URL involving search params (
?
) and the fragment (#
). Something like Elm Land's Page.withOnUrlChanged, although I haven't used that personally.My personal use case is that I have a static blog built with elm-pages, and one page is the tag page, which uses a
?t=tag
query to list posts matching a tag. I was able to do this with v2 because when the URL changed, the page re-initted, so the model was rebuilt.The text was updated successfully, but these errors were encountered: