fix(nuxt): call data refresh hook in parallel (#8470)

This commit is contained in:
Daniel Roe 2022-10-25 17:29:35 +02:00 committed by GitHub
parent 91eab1b312
commit 1d795f0274
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -264,12 +264,12 @@ export function useLazyAsyncData<
return useAsyncData(key, handler, { ...options, lazy: true }, null) return useAsyncData(key, handler, { ...options, lazy: true }, null)
} }
export function refreshNuxtData (keys?: string | string[]): Promise<void> { export async function refreshNuxtData (keys?: string | string[]): Promise<void> {
if (process.server) { if (process.server) {
return Promise.resolve() return Promise.resolve()
} }
const _keys = keys ? Array.isArray(keys) ? keys : [keys] : undefined const _keys = keys ? Array.isArray(keys) ? keys : [keys] : undefined
return useNuxtApp().callHook('app:data:refresh', _keys) await useNuxtApp().hooks.callHookParallel('app:data:refresh', _keys)
} }
export function clearNuxtData (keys?: string | string[] | ((key: string) => boolean)): void { export function clearNuxtData (keys?: string | string[] | ((key: string) => boolean)): void {