Skip to content

Interface: VanillaRouter

API / @xmachines/play-dom-router / VanillaRouter

Defined in: play-dom-router/src/create-router.ts:24

The router that createRouter builds and returns.

The router wraps a BrowserHistory and a RouteTree, and it does nothing more. It OWNS the history, and the history patches window.history.pushState, so a caller that drops the router without destroy() leaves the global patched. A scope can do that work: publish the router with asDisposable of @xmachines/core/utils, and name destroy as the release:

const plain = createRouter({ routeTree, history });
using router = asDisposable(plain, () => plain.destroy());

destroy() covers the HISTORY alone. connectRouter hands back its own RouterConnection, and a scope that ends releases no connection for the caller: release the connection first, then the router.

destroy() is idempotent, because BrowserHistory.destroy is.

Properties

PropertyModifierTypeDescriptionDefined in
historyreadonlyBrowserHistoryThe history instanceplay-dom-router/src/create-router.ts:28
routeTreereadonlyRouteTreeThe route tree, as a reference to the structureplay-dom-router/src/create-router.ts:33

Methods

destroy()

destroy(): void;

Defined in: play-dom-router/src/create-router.ts:38

Cleans up

Returns

void