question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

export to xstate format

See original GitHub issue

Suggestion to produce xstate js output, would be really useful and provide wider audience for use with most popular js library for state charts/ state machines.

Ideally, would be available as an option in the exporter list in the ui side menu.

Example format, this includes its guard and action (onEntry, onExit) features, but even a more limited/simplistic output of the events and actions would be beneficial:

var stateMachine = new xstate.Machine({
  initial: "not_green",
  states: {
    not_green: {
      on: {
        change:  {
          green: {
            cond: (text) => text.length > 0
          }
        }
      }
    },
    green: {
      onEntry: "startHttpRequest",
      onExit: "cancelHttpRequest",
      on: {
        results: "not_green",
        change:  {
          not_green: {
            cond: (text) => text.length == 0
          }
        }
      }
    }
  }
});

Website: https://xstate.js.org/docs/

Notice they have there on visualiser, but your tool and syntax/lang is much easier to use for mocking up.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:6
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
sverweijcommented, Jul 29, 2019

(I’ve published a polished version to live yesterday)

3reactions
sverweijcommented, Jul 27, 2019

@davidkpiano couldn’t sleep very well last night so I wrote an scxml parser (see PR above). Which means that scxml output should be enough to get it visualized.

Available on http://sverweij.gitlab.io/state-machine-cat/ and on npm behind the beta tag; state-machine-cat@beta - hope to publish at the start of next week (some edge & corner cases need to be covered + some refactoring from late-night code to something a bit better).

(That said - a direct mapping to and from xstate might still be useful …)

Read more comments on GitHub >

github_iconTop Results From Across the Web

XState Docs
Documentation for XState: State Machines and Statecharts for the Modern Web.
Read more >
Create Or Update Form - XState Catalogue
Create / Update Form ... Submitting the form ... import { assign, createMachine, Sender } from 'xstate'; export interface CreateOrUpdateFormMachineContext ...
Read more >
Using state machines with XState and React - LogRocket Blog
Inside of our XState Visualizer, we'll first write a simple state machine to create a new book for our book store: export const...
Read more >
Building a Multi-Step Checkout Form from Scratch | Upstatement
When initially strategizing about the checkout form we were going to build, ... createMachine } from 'xstate'; export const checkoutMachine ...
Read more >
StatesKit | Visual Statechart and Finite State Machine editor
Drop existing statechart files (in Xstate format) and start editing immediately, when done just export and download a new javascript file or copy...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found