Skip to content

Commit

Permalink
perf(client): use eager computed for routePath to avoid extra route l…
Browse files Browse the repository at this point in the history
…ocale resolving
  • Loading branch information
meteorlxy committed Jul 3, 2023
1 parent 3fbe54f commit aacff56
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/client/src/setupGlobalComputed.ts
Expand Up @@ -59,13 +59,12 @@ export const setupGlobalComputed = (
router: Router,
clientConfigs: ClientConfig[]
): GlobalComputed => {
// create global computed
const layouts = computed(() => resolvers.resolveLayouts(clientConfigs))
// create eager computed for route path and locale, so that route changes
// won't make all downstream computed re-evaluate
const routePath = computedEager(() => router.currentRoute.value.path)
const routeLocale = computedEager(() =>
resolvers.resolveRouteLocale(
siteData.value.locales,
router.currentRoute.value.path
)
resolvers.resolveRouteLocale(siteData.value.locales, routePath.value)
)
const siteLocaleData = computed(() =>
resolvers.resolveSiteLocaleData(siteData.value, routeLocale.value)
Expand Down

0 comments on commit aacff56

Please sign in to comment.