import type { State } from "@real-router/core"; export interface RouteExitContext { /** The route being left. */ route: State; /** The route being navigated to. */ nextRoute: State; /** * AbortSignal that fires when this navigation is superseded by a later * one (rapid clicks). Already filtered: when the handler runs, * `signal.aborted` is guaranteed to be `false`. Use * `signal.addEventListener("abort", cleanup, { once: true })` for * cleanup that must run on cancellation. */ signal: AbortSignal; } export interface UseRouteExitOptions { /** * Skip the handler when `route.name === nextRoute.name` * (sort/filter/query-only navigations on the same route). Default: * `true`. */ skipSameRoute?: boolean; } export type RouteExitHandler = (context: RouteExitContext) => void | Promise; /** * Subscribe to the router's leave-window with the universal guards baked * in. Wraps `router.subscribeLeave` so consumers don't repeat the same * boilerplate every time: * * - **Reentrant abort pre-check**: if `signal.aborted` is already `true` * when the handler would run (rapid navigation superseded a slower * one), the handler is skipped entirely. * - **Same-route skip**: by default, `route.name === nextRoute.name` * short-circuits the handler — query-only navigations skip the work. * Opt out with `skipSameRoute: false`. * * Cleanup is bound to the component via `onDestroy`. Must be called * during component initialization (synchronous in ` * *
...
* ``` * * @example Reading rich transition metadata via `nextRoute.transition` * ```svelte * * ``` */ export declare function useRouteExit(handler: RouteExitHandler, options?: UseRouteExitOptions): void;