Skip to content

Class: TanStackSolidRouterBridge

API / @xmachines/play-tanstack-solid-router / TanStackSolidRouterBridge

Defined in: play-tanstack-solid-router/src/solid-router-bridge.ts:43

TanStack Solid Router adapter that implements the RouterBridge protocol through TanStackRouterBridgeBase

Remarks

All the behavior is in the shared TanStackRouterBridgeBase. Its own documentation gives the reason for the history subscription and the rules of the first synchronization. This subclass binds the adapter to the Solid version of TanStack Router, and it keeps the dispose() alias.

Call onCleanup(() => bridge.disconnect()) in your Solid component. The bridge then disconnects on unmount.

Extends

Constructors

Constructor

new TanStackSolidRouterBridge(
router,
actor,
routeMap): TanStackSolidRouterBridge;

Defined in: play-tanstack-router/src/tanstack-router-bridge-base.ts:117

Creates a TanStack Router bridge

Parameters

ParameterTypeDescription
routerTanStackRouterLikeThe TanStack Router instance from createRouter
actorRoutableActorThe XMachines actor instance
routeMapTanStackRouteMapLikeThe bidirectional map between the state IDs and the paths

Returns

TanStackSolidRouterBridge

Inherited from

TanStackRouterBridgeBase.constructor

Methods

connect()

connect(): void;

Defined in: play-router/src/router-bridge-base.ts:158

Connects the router bridge to the Actor.

The method installs the TC39 Signal watcher of the direction from the actor to the router. It then starts the watch of the router changes, which each framework does in its own way.

The order of these steps is part of the contract of the bridge:

  • The constructor seeds lastSyncedPath from actor.currentRoute
  • The method installs the actor watcher before the router subscriptions of the adapter
  • The first synchronization then separates a deep link from a restore, with actor.initialRoute

An adapter that needs a different behavior of the first synchronization overrides getInitialRouterPath(). It does not change the order of the steps of connect().

Returns

void

Inherited from

TanStackRouterBridgeBase.connect


disconnect()

disconnect(): void;

Defined in: play-router/src/router-bridge-base.ts:270

Disconnects the router bridge from the Actor.

The method stops the watch of the signal, and it removes the router listener of the framework.

Returns

void

Inherited from

TanStackRouterBridgeBase.disconnect


dispose()

dispose(): void;

Defined in: play-tanstack-solid-router/src/solid-router-bridge.ts:49

Disposes of the bridge. This method is the alias of disconnect.

Returns

void

Deprecated

Use disconnect. Will be removed in the next major.