(path, options = {})
| 380 | } |
| 381 | |
| 382 | export async function prefetch(path, options = {}) { |
| 383 | // Clean the path |
| 384 | path = getRoutePath(path) |
| 385 | |
| 386 | const { type } = options |
| 387 | |
| 388 | // If it's priority, we stop the queue temporarily |
| 389 | if (options.priority) { |
| 390 | requestPool.stop() |
| 391 | } |
| 392 | |
| 393 | let data |
| 394 | if (type === 'data') { |
| 395 | data = await prefetchData(path, options) |
| 396 | } else if (type === 'template') { |
| 397 | await prefetchTemplate(path, options) |
| 398 | } else { |
| 399 | ;[data] = await Promise.all([ |
| 400 | prefetchData(path, options), |
| 401 | prefetchTemplate(path, options), |
| 402 | ]) |
| 403 | } |
| 404 | |
| 405 | // If it was priority, start the queue again |
| 406 | if (options.priority) { |
| 407 | requestPool.start() |
| 408 | } |
| 409 | |
| 410 | return data |
| 411 | } |
| 412 | |
| 413 | export function isPrefetchableRoute(path) { |
| 414 | // when rendering static pages we dont need this at all |
no test coverage detected
searching dependent graphs…