-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How about making the viz a drop-in visualizer to any application? #15
Comments
I was thinking about a less intrusive option. The option is using a hook that collects metadata in development mode of all statecharts in your app and automatically shows a debugger window (with a button or with a keyboard shortcut). It'll allow you to navigate over all your statecharts and if possible change the state. All this would be done with a global config. Maybe implementing it as an experimental file on the import { useMachine, configViz } from 'use-machine/experimental'
configViz({ withButton: true }) // one global call that enable the viz
const App = () => {
const [current, send] = useMachine(MainMachine)
return (
<div>
{JSON.stringify(current.value)}
</div>
)
} What do you think? |
Sounds good to me! 👍👍 |
I recently got the visualizer working locally on my React + TS codebase by a similar approach. Following a discussion with @davidkpiano, I'm working on a small CLI to be able to open visualizer for any machine the same way tools like webpack-bundle-analyzer work. Therefore, anyone would be able to visualize all the machines in their codebase using es modules and file path references. {
"visualize": "xstate-viz --file path_to_the_file_with_default_export_machine --open"
} Will submit a WIP PR soon. Stay tuned! |
Also if you're looking for a sneak peek into how it works for my project right now, here are two files from the project. https://github.com/farskid/hslzone/blob/master/src/components/App/AppWithMachine.tsx |
Great, @farskid! |
I would much prefer a visualization tool that generates SVG from state machine objects. This way it would be framework-agnostic and potentially usable from command line. |
@sesm, are you aware of https://github.com/lucmartens/xstate-plantuml? |
@farskid, I am very interested in your work. As I'm working much in Vue codebases these day, there might also be a change to use the visualizer components via https://github.com/akxcv/vuera ... |
@riddla Thanks for sharing plantuml project and the kind words :) we're working on the a vscode extension for the visualization. stay tuned. |
Hello @farskid, I tried running your code and I'm getting following error. Do you know how can I fix it? |
@Indrajeetsing it's a dependency error, you probably need to install the dependencies again |
@Indrajeetsing Seems that the You'd need to lock your More feasibility talk in #67. |
Need assistance on how to visualize xsate chart of my state machine on my native react app, without any need to visit - https://xstate.js.org/viz/. Have gone through the comments in this discussion , but could not find anything exactly for my requirement |
@piku0709 it's possible to do on web with statechart-viz, but it will be static, without any live updates on state change, unless you pass a new state to visualiser every time it changes. If you need it work in React Native, you have two options:
but I wouldn't do anything of it and tried to patch |
@serhiipalash - Thank you for your suggestions |
@piku0709 great! |
I just did a quick POC to make
xstate-viz
a drop-in visualizer in a react app so that it could be toggled on and off as needed, see it in action hereSample code below, basically the viz component lives with-in the real project and will be updated whenever the machine content was changed.
As a side note, it would be great to toggle show/hide of the sidebar by an argument.
The text was updated successfully, but these errors were encountered: