fix(nuxt3): add app:suspense:resolve hooks (#2937)

This commit is contained in:
Daniel Roe 2022-01-26 17:24:54 +00:00 committed by GitHub
parent b449d0bfb9
commit 00e8a6e9d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 2 deletions

View File

@ -48,7 +48,7 @@ if (process.client) {
await nuxt.hooks.callHook('app:created', vueApp)
await nuxt.hooks.callHook('app:beforeMount', vueApp)
nuxt.hooks.hookOnce('page:finish', () => {
nuxt.hooks.hookOnce('app:suspense:resolve', () => {
nuxt.isHydrating = false
})

View File

@ -1,5 +1,5 @@
<template>
<Suspense>
<Suspense @resolve="onResolve">
<App />
</Suspense>
</template>
@ -14,6 +14,9 @@ export default {
if (process.dev && results && results.some(i => i && 'then' in i)) {
console.error('[nuxt] Error in `vue:setup`. Callbacks must be synchronous.')
}
return {
onResolve: () => nuxtApp.callHook('app:suspense:resolve')
}
}
}
</script>

View File

@ -20,6 +20,7 @@ export interface RuntimeNuxtHooks {
'app:beforeMount': (app: App<Element>) => HookResult
'app:mounted': (app: App<Element>) => HookResult
'app:rendered': () => HookResult
'app:suspense:resolve': (Component?: VNode) => HookResult
'page:start': (Component?: VNode) => HookResult
'page:finish': (Component?: VNode) => HookResult
'meta:register': (metaRenderers: Array<(nuxt: NuxtApp) => NuxtMeta | Promise<NuxtMeta>>) => HookResult