UNPKG

@tanstack/vue-router

Version:

Modern and scalable routing for Vue applications

37 lines 1.53 kB
import { batch, createStore } from '@tanstack/vue-store'; export const getStoreFactory = (_opts) => { return { createMutableStore: createStore, createReadonlyStore: createStore, batch, init: (stores) => { // Single derived store: one reactive node that maps every active // routeId to its child's matchId. Depends only on matchesId + // the pool's routeId tags (which are set during reconciliation). // Outlet reads the map and then does a direct pool lookup. stores.childMatchIdByRouteId = createStore(() => { const ids = stores.matchesId.state; const obj = {}; for (let i = 0; i < ids.length - 1; i++) { const parentStore = stores.activeMatchStoresById.get(ids[i]); if (parentStore?.routeId) { obj[parentStore.routeId] = ids[i + 1]; } } return obj; }); stores.pendingRouteIds = createStore(() => { const ids = stores.pendingMatchesId.state; const obj = {}; for (const id of ids) { const store = stores.pendingMatchStoresById.get(id); if (store?.routeId) { obj[store.routeId] = true; } } return obj; }); }, }; }; //# sourceMappingURL=routerStores.js.map