fix(nuxt): unsub from hooks when unmounting indicator (#22592)

This commit is contained in:
Daniel Roe 2023-08-11 13:15:02 +01:00 committed by GitHub
parent 8b61c29f93
commit 1a61cb22ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -54,14 +54,16 @@ export default defineComponent({
} }
}) })
nuxtApp.hook('page:finish', indicator.finish) const unsubPage = nuxtApp.hook('page:finish', indicator.finish)
nuxtApp.hook('vue:error', indicator.finish) const unsubError = nuxtApp.hook('vue:error', indicator.finish)
onBeforeUnmount(() => { onBeforeUnmount(() => {
const index = globalMiddleware.indexOf(indicator.start) const index = globalMiddleware.indexOf(indicator.start)
if (index >= 0) { if (index >= 0) {
globalMiddleware.splice(index, 1) globalMiddleware.splice(index, 1)
} }
unsubPage()
unsubError()
indicator.clear() indicator.clear()
}) })