How to use the xstate/lib/graph.getNodes function in xstate

To help you get started, we’ve selected a few xstate examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github davidkpiano / xviz / client / src / App.tsx View on Github external
attachElement(element: Element | null) {
    if (!element || this.interpreter) {
      return;
    }

    const { machine } = this.state;

    const nodes = utils.getNodes(machine);

    const graphNodes = [machine, ...nodes]
      .map(node => {
        const entryLabel = node.onEntry.length ? `\nentry / ${node.onEntry.join(',')}` : '';
        const exitLabel = node.onExit.length ? `\nexit / ${node.onExit.join(',')}` : '';
        return [
          {
            data: {
              id: node.id,
              label: node.key,
              parent: node.parent ? node.parent.id : undefined,
              parallel: node.parallel
            }
          },
          node.initial && {
            data: {