Skip to content

Force run route #29

Answered by webJose
Slonik asked this question in Q&A
Discussion options

You must be logged in to vote

Hello!

Interesting case! It sure can be done.

Option 1

This REPL shows how.

Explanation

  1. You declare a reactive variable to hold the promise that returns data.
  2. You get a hold of the router's RouterEngine object that holds the status data for all routes. This data is reactive.
  3. You add an $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 REPL


The second opt…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by Slonik
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #28 on March 09, 2025 05:26.