Class: SvelteKitRouterBridge
API / @xmachines/play-sveltekit-router / SvelteKitRouterBridge
Defined in: play-sveltekit-router/src/sveltekit-router-bridge.ts:40
The SvelteKit router bridge — it connects the SvelteKit navigation to RouterBridgeBase.
It implements the three abstract methods:
navigateRouter→goto(path, { noScroll: true, keepFocus: true })watchRouterChanges→ anafterNavigate()subscription through an indirection cellunwatchRouterChanges→ it sets the cell to null. This releases the bridge reference of the registered closure before the component unmounts
It overrides two optional hooks:
getInitialRouterPath→loc.pathnamegetInitialRouterSearch→loc.search
The bridge inherits the restore-or-deeplink detection and the lastSyncedPath
echo suppression from RouterBridgeBase.
Param
actor
A Routable actor.
Param
routeMap
The bidirectional route map.
Param
loc
The location-like object for the initial URL reads. The default
is globalThis.location. Give a mock in a test, or a stub in an SSR
environment.
Extends
Constructors
Constructor
new SvelteKitRouterBridge( actor, routeMap, loc?): SvelteKitRouterBridge;Defined in: play-sveltekit-router/src/sveltekit-router-bridge.ts:57
Parameters
| Parameter | Type |
|---|---|
actor | RoutableActor |
routeMap | RouteMap |
loc | LocationLike | null |
Returns
SvelteKitRouterBridge
Overrides
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
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: 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