AlexxNB / tinro

Highly declarative, tiny, dependency free router for Svelte's web applications.
MIT License
673 stars 30 forks source link

Is there a way to make router.params() reactive? #21

Closed jamauro closed 4 years ago

jamauro commented 4 years ago

When navigating between routes that have the same shape, e.g. /things/:id, it doesn't appear that router.params() is updated. Is there a way to make it reactive?

If I go back to /things and navigate to another /things/:id, it works as expected. If I pass in the param using the let:params, the params.id is updated as expected.

AlexxNB commented 4 years ago

You can use reactive statement:

$: params = router.params($router)

See example here - https://svelte.dev/repl/c711f397d4924ccda79224e8a3ee0ada?version=3.24.1

Maybe better way which will be use stores will be implemented in future versions.