ca1989
A live component and the query string
Hi all,
this may sound silly but I have some doubts regarding a live component and the query params.
I want to develop a live component (which is a list of items) that would keep as its state the items and let’s say the ordering.
I want my component (or the live view?) to update the query string when the user change the ordering.
Now, my doubt is: who’s responsible for updating the query string? The component or the live view?
My goal is to reuse the component in multiple pheonix projects, so I would like to have it as much self-contained as possible.
Cheers!
Marked As Solved
trisolaran
I would personally try that approach. And at the same time, if needed, the component could provide some helper to allow the LiveView to easily convert the sorting into a query string
Also Liked
LostKobrakai
URL handling is always the responsibility of the (root) LV. By definition there’s just a single URL, so you need to have a single place to coordinate changes to it. It makes the most sense to do that in the root LV, which also has the handle_params callback for reacting to url changes.







