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

Mark code to only run in load during an actual navigation #13112

Open
MathiasWP opened this issue Dec 6, 2024 · 0 comments
Open

Mark code to only run in load during an actual navigation #13112

MathiasWP opened this issue Dec 6, 2024 · 0 comments

Comments

@MathiasWP
Copy link
Contributor

Describe the problem

Is there a possibility mark a piece of code as only runnable when an actual navigation has occurred in a load?

export const load = async function ({ route }) {
	/**
	* Some other code fetching data that will be shown when entering the page
	*/

	// This will now run on pre-load since it references route.id, so there's no guarantee that the user visited the page if pre-load was on hover
	track('visited page', {
		route: route.id // Tracking that a page was visited
	})
};

Describe the proposed solution

A way to mark a piece of code as only runnable when the actual navigation has been performed

Alternatives considered

Moving it into the +page.svelte file, but it can quickly clutter up the +page.svelte file if there's a lot of things you just want to run during a navigation.

Importance

would make my life easier

Additional Information

No response

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

No branches or pull requests

1 participant