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

Add store to detect query changing #6

Merged
merged 1 commit into from
Apr 29, 2021
Merged

Add store to detect query changing #6

merged 1 commit into from
Apr 29, 2021

Conversation

ykrods
Copy link
Owner

@ykrods ykrods commented Apr 29, 2021

This will add a store to detect changes that the URL (including query string or hash) has been modified.

Routing depends on path (location.pathname) as same as before.

Example

<script>
  import { currentURL } from "svelte-spa-history-router";

  $: name = $currentURL.searchParams.get("name") || 'unknown';
</script>
<div>{ name }</div>

Note

Assumed use case likes giving initial selected value to search (filter) form from a link. but it may be a better solution to use store (in trial)

@ykrods ykrods merged commit f85a488 into main Apr 29, 2021
@ykrods ykrods deleted the querystring branch April 29, 2021 11:33
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.

1 participant