Function: createRouteMap()
API / @xmachines/play-vue-router / createRouteMap
function createRouteMap(machine, options?): RouteMap;Defined in: play-router/src/create-route-map.ts:45
Create a RouteMap from an XState state machine.
Extracts all routable states (those with meta.route) and builds a bidirectional
path ↔ stateId lookup structure. The returned map is used by RouterBridgeBase
subclasses to translate browser URL changes into play.route actor events and
vice-versa.
Parameters
| Parameter | Type | Description |
|---|---|---|
machine | AnyStateMachine | XState v5 state machine with meta.route annotations on states. |
options? | RouteMapOptions | Optional configuration. Pass { cacheSize } to override the default LRU cache size for parameterized path lookups. |
Returns
A RouteMap for passing to any RouterBridgeBase-based adapter.
Example
import { createRouteMap } from "@xmachines/play-router";import { connectRouter } from "@xmachines/play-dom-router";
const routeMap = createRouteMap(myMachine);const disconnect = connectRouter({ actor, router, routeMap });