Skip to content

Interface: DisposableVanillaRouter<History>

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

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

The router that createRouter returns: a VanillaRouter that a using scope can hold.

The router OWNS the history, and the history patches window.history.pushState. It was the one release of this package that a scope could not hold: the history, a subscription of it, and the connection of the router each carry the protocol, and the router itself carried none, so a scope that forgot destroy() left the global patched.

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

using router = createRouter({ routeTree, history });

The key sits on THIS type and not on VanillaRouter, exactly as DisposableBrowserHistory sits beside BrowserHistory: a caller that builds a router of its own — a test double, or a router of another history — keeps a type that asks for no dispose key.

A caller that keeps destroy() keeps it: the two release the same work, and the release is idempotent because BrowserHistory.destroy is.

Extends

Type Parameters

Type ParameterDefault type
History extends BrowserHistoryBrowserHistory

Properties

PropertyModifierTypeDescriptionInherited fromDefined in
historyreadonlyHistoryThe history instanceVanillaRouter.historyplay-dom-router/src/create-router.ts:21
routeTreereadonlyRouteTreeThe route tree, as a reference to the structureVanillaRouter.routeTreeplay-dom-router/src/create-router.ts:26

Methods

[dispose]()

dispose: void;

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

Returns

void


destroy()

destroy(): void;

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

Cleans up

Returns

void

Inherited from

VanillaRouter.destroy