-
If a route is active
and I try to call it again from function (after data update)
it doesn't work because this route already active (params.id not changed). |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hello! Interesting case! It sure can be done. Option 1This REPL shows how. Explanation
Then there is this button named "Refresh Data". This button, when clicked, re-runs the function that retrieves data, and assigns a new promise object to the variable specified in the Option 2Use an artificial reactive value with The second option is the quickest, but with the first one you learn a lot more about how the router works. 👍 |
Beta Was this translation helpful? Give feedback.
-
The second option looks much simpler. |
Beta Was this translation helpful? Give feedback.
Hello!
Interesting case! It sure can be done.
Option 1
This REPL shows how.
Explanation
RouterEngine
object that holds the status data for all routes. This data is reactive.$effect
that does the initial load, when the route becomes active for the first time.Then there is this button named "Refresh Data". This button, when clicked, re-runs the function that retrieves data, and assigns a new promise object to the variable specified in the
{#await}
block, forcing a "re-run" of the route's content.Option 2
Use an artificial reactive value with
{#key}
. This REPLThe second opt…