feat: onServerPrefetch (#3070)
Support equivalent of `serverPrefetch` option via Composition API.
This commit is contained in:
@@ -153,7 +153,7 @@ export type Component<
|
||||
|
||||
export { ComponentOptions }
|
||||
|
||||
type LifecycleHook = Function[] | null
|
||||
type LifecycleHook<TFn = Function> = TFn[] | null
|
||||
|
||||
export const enum LifecycleHooks {
|
||||
BEFORE_CREATE = 'bc',
|
||||
@@ -168,7 +168,8 @@ export const enum LifecycleHooks {
|
||||
ACTIVATED = 'a',
|
||||
RENDER_TRIGGERED = 'rtg',
|
||||
RENDER_TRACKED = 'rtc',
|
||||
ERROR_CAPTURED = 'ec'
|
||||
ERROR_CAPTURED = 'ec',
|
||||
SERVER_PREFETCH = 'sp'
|
||||
}
|
||||
|
||||
export interface SetupContext<E = EmitsOptions> {
|
||||
@@ -414,6 +415,10 @@ export interface ComponentInternalInstance {
|
||||
* @internal
|
||||
*/
|
||||
[LifecycleHooks.ERROR_CAPTURED]: LifecycleHook
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
[LifecycleHooks.SERVER_PREFETCH]: LifecycleHook<() => Promise<unknown>>
|
||||
}
|
||||
|
||||
const emptyAppContext = createAppContext()
|
||||
@@ -497,7 +502,8 @@ export function createComponentInstance(
|
||||
a: null,
|
||||
rtg: null,
|
||||
rtc: null,
|
||||
ec: null
|
||||
ec: null,
|
||||
sp: null
|
||||
}
|
||||
if (__DEV__) {
|
||||
instance.ctx = createRenderContext(instance)
|
||||
|
||||
Reference in New Issue
Block a user