Minor Changes
-
142f54e1
#1366 Thanks @davidkpiano! - ThetoDirectedGraph(...)
function was added, which converts amachine
into an object that can be used in many different graph-based and visualization tools:import { toDirectedGraph } from '@xstate/graph'; const machine = createMachine({/* ... */}); const digraph = toDirectedGraph(machine); // returns an object with this structure: { id: '...', stateNode: /* StateNode */, children: [ { id: '...', children: [/* ... */], edges: [/* ... */] }, { id: '...', /* ... */ }, // ... ], edges: [ { source: /* ... */, target: /* ... */, transition: /* ... */ } // ... ] }