- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 2.1k
Closed
Labels
feature / enhancementNew feature or requestNew feature or requestp2-nice-to-haveSvelteKit cannot be used by a small number of people, quality of life improvements, etc.SvelteKit cannot be used by a small number of people, quality of life improvements, etc.router
Milestone
Description
Describe the problem
When running a load function, SvelteKit notes what dependencies the function has...
- url.pathname,- url.search, etc
- params.x,- params.y
- resources loaded with fetch
- await parent()
...and re-runs the function when those things change. It's possible to force an invalidation with invalidate(resource) (where the load function called depends(resource)) or with invalidate() (which invalidates all load functions), but it's not possible to opt out of invalidation, which is occasionally helpful:
- you want to log some values but not 'observe' them
- you want to implement more fine-grained invalidation, a la Page load functions should return props via derived stores #5850
Describe the proposed solution
We could add an untrack function to load:
export function load({ params, untrack }) {
  untrack(() => console.log(`this will not re-run when ${params.foo}` changes...`));
  console.log(`...but it will re-run when ${params.bar} changes`);
}Code executed synchronously inside the callback would not affect the function's dependencies.
Alternatives considered
The alternative is to require developers to be completely explicit about when load should re-run, or to always re-run every load function (which no-one wants).
Importance
nice to have
Additional Information
No response
mquandalle, madeleineostoja, stalkerg, TeyKey1, theetrain and 24 more
Metadata
Metadata
Assignees
Labels
feature / enhancementNew feature or requestNew feature or requestp2-nice-to-haveSvelteKit cannot be used by a small number of people, quality of life improvements, etc.SvelteKit cannot be used by a small number of people, quality of life improvements, etc.router