UNPKG

@tanstack/vue-router

Version:

Modern and scalable routing for Vue applications

37 lines 1.5 kB
import { batch, createAtom } from '@tanstack/vue-store'; export const getStoreFactory = (_opts) => { return { createMutableStore: createAtom, createReadonlyStore: createAtom, 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 = createAtom(() => { const ids = stores.matchesId.get(); const obj = {}; for (let i = 0; i < ids.length - 1; i++) { const parentStore = stores.matchStores.get(ids[i]); if (parentStore?.routeId) { obj[parentStore.routeId] = ids[i + 1]; } } return obj; }); stores.pendingRouteIds = createAtom(() => { const ids = stores.pendingIds.get(); const obj = {}; for (const id of ids) { const store = stores.pendingMatchStores.get(id); if (store?.routeId) { obj[store.routeId] = true; } } return obj; }); }, }; }; //# sourceMappingURL=routerStores.js.map