Skip to content
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

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

Merged
merged 1 commit into from Jul 3, 2022

Conversation

edelvalle
Copy link
Owner

@edelvalle edelvalle commented May 18, 2022

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 edelvalle force-pushed the encode-state-in-url branch 4 times, most recently from 154abe4 to 3d507e9 Compare June 15, 2022 19:48
@edelvalle
Copy link
Owner Author

@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
Copy link
Contributor

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.

@edelvalle edelvalle merged commit db9c2e1 into master Jul 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants