@param {import('./types.js').NavigationIntent} intent
(intent)
| 473 | |
| 474 | /** @param {import('./types.js').NavigationIntent} intent */ |
| 475 | async 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 |
no test coverage detected