Skip to content

Interface: RouteTree<TGraph>

API / @xmachines/play-router / index / RouteTree

Defined in: packages/play-router/src/types.ts:218

The complete route tree, with its lookup maps

It gives you the map between a state ID and a URL path, in both directions:

  • byStateId: it maps each state ID to its route node, for the target of a play.route event
  • byPath: it maps each URL path to its route node, for the browser navigation

Type Parameters

Type ParameterDefault type
TGraphunknown

Properties

PropertyTypeDescriptionDefined in
byPathMap<string, RouteNode>The map from a complete path to its route node. It gives you the state ID of a URL path, for the target of a play.route eventpackages/play-router/src/types.ts:230
byStateIdMap<string, RouteNode>The map from a state ID to its route node. It gives you the URL path of a state ID, for the update of the browser URLpackages/play-router/src/types.ts:225
graph?TGraphThe graph of the state machine, for an advanced query. TGraph carries its type, and this package names none: a route tree is a map from a path to a state, and the graph of a MACHINE belongs to the package that reads a machine. extractMachineRoutes of @xmachines/play-router/xstate answers RouteTree<MachineGraph>, so a consumer of that function loses no type. Example import { getSuccessors, hasPath } from "@statelyai/graph"; // treecomes fromextractMachineRoutesof@xmachines/play-router/xstate const successors = getSuccessors(tree.graph!, "myMachine.home");packages/play-router/src/types.ts:246
rootRouteNodeThe root node of the routespackages/play-router/src/types.ts:220