github statelyai/xstate @xstate/graph@1.2.0

3 years ago

Minor Changes

  • 142f54e1 #1366 Thanks @davidkpiano! - The toDirectedGraph(...) function was added, which converts a machine 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: /* ... */ }
        // ...
      ]
    }

Don't miss a new xstate release

NewReleases is sending notifications on new releases.