Interface: RouterBridge
API / @xmachines/play-vue-router / RouterBridge
Defined in: play-router/src/types.ts:341
RouterBridge interface for runtime infrastructure adapters
Defines the lifecycle connection between Infrastructure (e.g., a framework router) and the Actor. Infrastructure “bridges” to the Actor by observing its signals and managing its own lifecycle accordingly.
Architectural Context: Implements Passive Infrastructure (INV-04) by establishing a unidirectional observation pattern. Infrastructure connects to observe Actor signals (currentRoute, currentView, state) and reflects changes without making state decisions.
Example
Framework router bridge implementation
import type { RouterBridge } from "@xmachines/play-router";import { Signal } from "@xmachines/play-signals";
class MyRouterBridge implements RouterBridge { private watcher: Signal.Watcher | null = null;
async connect(): Promise<void> { // Start observing actor.currentRoute signal this.watcher = new Signal.subtle.Watcher(() => { const route = actor.currentRoute.get(); if (route) router.navigate(route); }); this.watcher.watch(actor.currentRoute); }
async disconnect(): Promise<void> { // Stop observing, cleanup watchers this.watcher?.unwatch(actor.currentRoute); this.watcher = null; }}See
Play RFC - Invariant INV-04
Methods
connect()
connect(): void | Promise<void>;Defined in: play-router/src/types.ts:357
Connect the router bridge to the Actor
Called when Infrastructure should begin observing Actor signals and synchronizing its state (e.g., browser URL) with Actor state.
Returns
void | Promise<void>
Promise that resolves when connection is established, or void for synchronous connection
Example
const bridge: RouterBridge = createBridge(actor, router);await bridge.connect();// Bridge now observing actor.currentRoute signaldisconnect()
disconnect(): void | Promise<void>;Defined in: play-router/src/types.ts:373
Disconnect the router bridge from the Actor
Called when Infrastructure should stop observing and clean up resources (e.g., signal watchers, event listeners).
Returns
void | Promise<void>
Promise that resolves when disconnection is complete, or void for synchronous disconnection
Example
await bridge.disconnect();// Bridge stopped observing, resources cleaned up