async function invalidate()

in kit/svelteKitCustomClient/client.js [175:206]


	async function invalidate() {
		// Accept all invalidations as they come, don't swallow any while another invalidation
		// is running because subsequent invalidations may make earlier ones outdated,
		// but batch multiple synchronous invalidations.
		pending_invalidate = pending_invalidate || Promise.resolve();
		await pending_invalidate;
		if (!pending_invalidate) return;
		pending_invalidate = null;

		const url = new URL(location.href);
		const intent = get_navigation_intent(url, true);
		// Clear preload, it might be affected by the invalidation.
		// Also solves an edge case where a preload is triggered, the navigation for it
		// was then triggered and is still running while the invalidation kicks in,
		// at which point the invalidation should take over and "win".
		load_cache = null;

		const nav_token = (token = {});
		const navigation_result = intent && (await load_route(intent));
		if (nav_token !== token) return;

		if (navigation_result) {
			if (navigation_result.type === "redirect") {
				return goto(new URL(navigation_result.location, url).href, {}, [url.pathname], nav_token);
			} else {
				if (navigation_result.props.page !== undefined) {
					page = navigation_result.props.page;
				}
				root.$set(navigation_result.props);
			}
		}
	}