()
| 364 | |
| 365 | // Create or use a shared asyncData entity |
| 366 | function createInitialFetch () { |
| 367 | const initialFetchOptions: AsyncDataExecuteOptions = { cause: 'initial', dedupe: opts.dedupe } |
| 368 | const existing = nuxtApp._asyncData[key.value] |
| 369 | if (!existing?._init) { |
| 370 | initialFetchOptions.cachedData = opts.getCachedData!(key.value, nuxtApp, { cause: 'initial' }) |
| 371 | nuxtApp._asyncData[key.value] = buildAsyncData(nuxtApp, key.value, _handler, opts, initialFetchOptions.cachedData) |
| 372 | nuxtApp._asyncData[key.value]!._initialCachedData = initialFetchOptions.cachedData |
| 373 | } else if (nuxtApp._asyncDataPromises[key.value]) { |
| 374 | // reuse the cache lookup performed by the first concurrent caller while their fetch is still in flight |
| 375 | initialFetchOptions.cachedData = existing._initialCachedData |
| 376 | } |
| 377 | // otherwise let execute() perform a fresh getCachedData lookup so subscribers that mount |
| 378 | // after the initial fetch has settled still go through getCachedData (#35116) |
| 379 | return () => nuxtApp._asyncData[key.value]!.execute(initialFetchOptions) |
| 380 | } |
| 381 | |
| 382 | const initialFetch = createInitialFetch() |
| 383 | const asyncData = nuxtApp._asyncData[key.value]! |
no test coverage detected
searching dependent graphs…