edelvalle / reactor

Phoenix LiveView but for Django
635 stars 26 forks source link

Allow components to encode part of their state in the URL #42

Closed edelvalle closed 2 years ago

edelvalle commented 2 years ago

By defining this:

class Search(Component):
    query: str

    _url_params = {"query": "search_query"}

When the object state changes it will replace the URL updating the GET parameters to include search_query=whatever so the state of the view can be restored when the URL is shared or the user goes back to it.

edelvalle commented 2 years ago

@adamghill May I interest you, sir., in encoding part of a component state in the URL as a GET parameter? Check out the README.md and the example inside of tests/

adamghill commented 2 years ago

This is an awesome idea! Nice work. 👍 It reminds me of https://laravel-livewire.com/docs/2.x/query-string which I've looked at before and wondered if it would be useful for Unicorn.