refactor: export AsyncDataStrategy

This commit is contained in:
Daniel Roe 2023-07-25 09:50:51 +01:00
parent 6abab412ad
commit 8e18c1bdc0
2 changed files with 5 additions and 3 deletions

View File

@ -31,6 +31,8 @@ export type KeyOfRes<Transform extends _Transform> = KeysOf<ReturnType<Transform
export type MultiWatchSources = (WatchSource<unknown> | object)[] export type MultiWatchSources = (WatchSource<unknown> | object)[]
export type AsyncDataStrategy = 'lazy' | 'parallel' | 'blocking'
export interface AsyncDataOptions< export interface AsyncDataOptions<
ResT, ResT,
DataT = ResT, DataT = ResT,
@ -40,7 +42,7 @@ export interface AsyncDataOptions<
server?: boolean server?: boolean
/** @deprecated Use strategy: 'lazy' */ /** @deprecated Use strategy: 'lazy' */
lazy?: boolean lazy?: boolean
strategy?: 'lazy' | 'parallel' | 'blocking' strategy?: AsyncDataStrategy
default?: () => DefaultT | Ref<DefaultT> default?: () => DefaultT | Ref<DefaultT>
transform?: _Transform<ResT, DataT> transform?: _Transform<ResT, DataT>
pick?: PickKeys pick?: PickKeys

View File

@ -14,7 +14,7 @@ import type { RenderResponse } from 'nitropack'
import type { NuxtIslandContext } from '../core/runtime/nitro/renderer' import type { NuxtIslandContext } from '../core/runtime/nitro/renderer'
import type { RouteMiddleware } from '../../app' import type { RouteMiddleware } from '../../app'
import type { NuxtError } from '../app/composables/error' import type { NuxtError } from '../app/composables/error'
import type { AsyncDataOptions, AsyncDataRequestStatus } from '../app/composables/asyncData' import type { AsyncDataRequestStatus, AsyncDataStrategy } from '../app/composables/asyncData'
const nuxtAppCtx = /* #__PURE__ */ getContext<NuxtApp>('nuxt-app') const nuxtAppCtx = /* #__PURE__ */ getContext<NuxtApp>('nuxt-app')
@ -103,7 +103,7 @@ interface _NuxtApp {
[key: string]: unknown [key: string]: unknown
/** @internal */ /** @internal */
_asyncDataPromises: Record<string, Promise<any> & { strategy?: AsyncDataOptions<any>['strategy'] } | undefined> _asyncDataPromises: Record<string, Promise<any> & { strategy?: AsyncDataStrategy } | undefined>
/** @internal */ /** @internal */
_asyncData: Record<string, { _asyncData: Record<string, {
data: Ref<any> data: Ref<any>