Class: SolidRouterBridge
API / @xmachines/play-solid-router / SolidRouterBridge
Defined in: packages/play-solid-router/src/solid-router-bridge.ts:58
The SolidJS Router integration bridge. It extends RouterBridgeBase
The class implements the RouterBridge protocol for SolidJS Router with the reactive primitives of Solid. The actor-to-router direction uses the TC39 Signal watcher of the base class. The router-to-actor direction uses the Solid createEffect function for a native reactivity.
The bridge reads each path parameter from the reactive useParams() proxy of
Solid. It does not parse the URL again with URLPattern. Therefore a
parameterized route works without the URLPattern polyfill, because the router of
Solid holds the values already.
Extends
Constructors
Constructor
new SolidRouterBridge( solidNavigate, location, params, actor, routeMap): SolidRouterBridge;Defined in: packages/play-solid-router/src/solid-router-bridge.ts:81
Creates a SolidJS Router bridge
CRITICAL: call connect() inside a Solid component, where the hooks are available.
Parameters
| Parameter | Type | Description |
|---|---|---|
solidNavigate | Navigator | The result of the useNavigate() hook |
location | LocationLike | The result of the useLocation() hook |
params | Params | The result of the useParams() hook. The bridge reads each path parameter directly from it. A parameterized route therefore does not need the URLPattern polyfill |
actor | RoutableActor | The XMachines actor instance |
routeMap | RouteMap | The bidirectional map between the state IDs and the paths |
Returns
SolidRouterBridge
Overrides
Methods
connect()
connect(): void;Defined in: packages/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
lastSyncedPathfromactor.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
disconnect()
disconnect(): void;Defined in: packages/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
dispose()
dispose(): void;Defined in: packages/play-solid-router/src/solid-router-bridge.ts:202
Disposes of the bridge. This method is the alias of disconnect.
Returns
void
Example
onCleanup(() => bridge.dispose());Deprecated
Use disconnect. Will be removed in the next major.