MCPcopy
hub / github.com/sveltejs/kit / _preload_data

Function _preload_data

packages/kit/src/runtime/client/client.js:475–498  ·  view source on GitHub ↗

@param {import('./types.js').NavigationIntent} intent

(intent)

Source from the content-addressed store, hash-verified

473
474/** @param {import('./types.js').NavigationIntent} intent */
475async function _preload_data(intent) {
476 // Reuse the existing pending preload if it's for the same navigation.
477 // Prevents an edge case where same preload is triggered multiple times,
478 // then a later one is becoming the real navigation and the preload tokens
479 // get out of sync.
480 if (intent.id !== load_cache?.id) {
481 const preload = {};
482 preload_tokens.add(preload);
483 load_cache = {
484 id: intent.id,
485 token: preload,
486 promise: load_route({ ...intent, preload }).then((result) => {
487 preload_tokens.delete(preload);
488 if (result.type === 'loaded' && result.state.error) {
489 // Don't cache errors, because they might be transient
490 load_cache = null;
491 }
492 return result;
493 })
494 };
495 }
496
497 return load_cache.promise;
498}
499
500/**
501 * @param {URL} url

Callers 2

preloadFunction · 0.85
preloadDataFunction · 0.85

Calls 2

load_routeFunction · 0.85
thenMethod · 0.45

Tested by

no test coverage detected