export to xstate format
See original GitHub issueSuggestion 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:
- Created 4 years ago
- Reactions:6
- Comments:10 (6 by maintainers)
Top Results From Across the Web
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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
(I’ve published a polished version to live yesterday)
@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 …)