From d5aee9062db36c4eff614cb5eb997d473977affd Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Mon, 19 Aug 2024 17:46:33 -0400 Subject: [PATCH] Group watch() together --- .../components/tree/ListTree.vue | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/arches_references/src/arches_references/components/tree/ListTree.vue b/arches_references/src/arches_references/components/tree/ListTree.vue index 68f2004..6d4d909 100644 --- a/arches_references/src/arches_references/components/tree/ListTree.vue +++ b/arches_references/src/arches_references/components/tree/ListTree.vue @@ -65,16 +65,7 @@ const { setDisplayedRow } = inject(displayedRowKey) as unknown as { }; const route = useRoute(); -watch( - [ - () => { - return { ...route }; - }, - ], - ([newRoute]) => { - navigate(newRoute); - }, -); + const navigate = (newRoute: RouteLocationNormalizedLoadedGeneric) => { switch (newRoute.name) { case routeNames.splash: @@ -130,6 +121,18 @@ const navigate = (newRoute: RouteLocationNormalizedLoadedGeneric) => { } }; +// React to route changes. +watch( + [ + () => { + return { ...route }; + }, + ], + ([newRoute]) => { + navigate(newRoute); + }, +); + // Navigate on initial load of the tree. watch( tree,