Class: DomRouterBridge
API / @xmachines/play-dom-router / DomRouterBridge
Defined in: play-dom-router/src/dom-router-bridge.ts:26
The DOM router bridge — it puts a BrowserHistory from createBrowserHistory
behind the RouterBridgeBase protocol.
It implements the three abstract methods:
navigateRouter→history.push(path)watchRouterChanges→history.subscribe(...), and it keeps the unsubscribe handleunwatchRouterChanges→ it calls the handle that it kept
It overrides two optional hooks:
getInitialRouterPath→history.location.pathnamegetInitialRouterSearch→history.location.search
The bridge inherits the prevention of a circular update, the
restore-or-deeplink detection, and the lastSyncedPath deduplication from
RouterBridgeBase.
Use connectRouter for the usual case. Use this class directly when you need
full control of the connection lifecycle.
Extends
Constructors
Constructor
new DomRouterBridge( actor, routeMap, history): DomRouterBridge;Defined in: play-dom-router/src/dom-router-bridge.ts:34
Parameters
| Parameter | Type | Description |
|---|---|---|
actor | RoutableActor | A Routable actor with currentRoute and send. |
routeMap | RouteLookupContract | The route lookup for both directions. Every object that satisfies RouteLookupContract works. |
history | BrowserHistory | The BrowserHistory instance from createBrowserHistory. |
Returns
DomRouterBridge
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