@tanstack/vue-router
Version:
Modern and scalable routing for Vue applications
26 lines (25 loc) • 1.23 kB
JavaScript
import { _isRouteDeparting } from "@tanstack/router-core";
import * as Vue from "vue";
//#region src/matchContext.tsx
var routeIdContext = Symbol("TanStackRouterRouteId");
var linkLocationContext = Symbol("TanStackRouterLinkLocation");
/**
* Provides the location the links below build from. A location publication
* whose navigation leaves `routeId` keeps the location the route still
* presents, so its links do no work: the route unmounts when that navigation
* commits, and any other outcome publishes a newer location. The store calls
* this subscription synchronously inside the publication, the only time the
* predicate is valid. Without a route the location is the live one. Links
* hand it to the router, so it stays raw rather than a readonly proxy.
*/
function provideLinkLocation(router, routeId) {
const store = router.stores.location;
const linkLocation = Vue.shallowRef(store.get());
Vue.onScopeDispose(store.subscribe((location) => {
if (!_isRouteDeparting(router, routeId, location)) linkLocation.value = location;
}).unsubscribe);
Vue.provide(linkLocationContext, linkLocation);
}
//#endregion
export { linkLocationContext, provideLinkLocation, routeIdContext };
//# sourceMappingURL=matchContext.js.map