mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 00:23:53 +00:00
perf(nuxt): unsubscribe from asyncData
watch when unmounted (#26821)
This commit is contained in:
parent
6d7a558c69
commit
468ebbdf0b
@ -375,7 +375,9 @@ export function useAsyncData<
|
||||
const hasScope = getCurrentScope()
|
||||
if (options.watch) {
|
||||
const unsub = watch(options.watch, () => asyncData.refresh())
|
||||
if (hasScope) {
|
||||
if (instance) {
|
||||
onUnmounted(unsub)
|
||||
} else if (hasScope) {
|
||||
onScopeDispose(unsub)
|
||||
}
|
||||
}
|
||||
@ -384,7 +386,9 @@ export function useAsyncData<
|
||||
await asyncData.refresh()
|
||||
}
|
||||
})
|
||||
if (hasScope) {
|
||||
if (instance) {
|
||||
onUnmounted(off)
|
||||
} else if (hasScope) {
|
||||
onScopeDispose(off)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user