Skip to content
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

[Experiment] Add xstate-devtools #439

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

[Experiment] Add xstate-devtools #439

wants to merge 5 commits into from

Conversation

jhen0409
Copy link
Owner

@jhen0409 jhen0409 commented Dec 1, 2019

This PR is integration for xstate-devtools browser extension (statecharts/xstate-viz#30). Implemented in a simple way like #298.

The XState core is used __REDUX_DEVTOOLS_EXTENSION__.connect, so it have simple logging feature with redux-devtools. The xstate-devtools wrapped the method and provided machine argument.

For RNDebugger, I added useXStateViz devTools option, allows users to choose simple logging on redux-devtools or the visualizer of xstate-devtools.

import { useMachine } from '@xstate/react'

const [current, send] = useMachine(machine, {
  devTools: { useXStateViz: true },
})

I think the final goal will be integrate xstate-viz into redux-devtools-core, it can be made more features that redux-devtools-extension has.

@Nohac
Copy link

Nohac commented Apr 29, 2020

Any updates on this? Is there any thing I can help out with to get this PR merged?


Edit: I tested this out by checking out this branch as well as rebasing master. It kind of works, but I'm not getting a graph, it only shows the current state. I suspect it's somewhat broken because the xstate devtool extension is a bit out of date. This is what it looks like for me:
Imgur

The version of xstate I use in my app is 4.9.1 while the devtools extension uses 4.6.7.

I'm also getting this error message in the console:

[178031:0430/121540.671083:ERROR:CONSOLE(1)] "TypeError: Cannot read property 'type' of null", source: chrome-extension://xstate-devtools/devtools/build/static/js/main.492902d9.chunk.js (1)

@jhen0409
Copy link
Owner Author

jhen0409 commented May 1, 2020

It's now on the official repo, it may have changed a lot.

I still using the old version for a while. I'm welcome to any help to upgrade that!

@Nohac
Copy link

Nohac commented Jun 26, 2020

@jhen0409 Hey, sorry for the late reply.
I worked on this for quite some time a while ago, but couldn't figure it out. It looks like the way devtools and redux connects have changed a lot from xstate-devtools to the new, and it doesn't help that I don't really know what I'm doing.

It would be great if @davidkpiano and @amitnovick could give us some pointers.

I do see this tool as a "must have" when working with xstate and react native, so it would be awesome if we could get this implemented soon.

@davidkpiano
Copy link

I am reworking the dev tools (first working on an embeddable visualizer) so it might be a few more weeks until dev tools are released.

However, there is the (undocumented) @xstate/viz package that contains React components for rendering machine visualizations:

import { MachineViz } from '@xstate/viz';

// ...
<MachineViz machine={someMachine} state={someState} />

Here is an example of that working: https://codesandbox.io/s/xstate-minute-timer-with-viz-g1cje

Let me know if that helps for now.

@cpetzel
Copy link

cpetzel commented Nov 5, 2020

It seems a lot has changed since this work was initiated. We have a new Inspector tool for web via the @xstate/inspect package, which is so much more powerful than the original visualizer.

I would love to attempt to get this new inspector working with React Native, and integrated into RNDebugger, but I can't seem to find the inspector front end code...

@davidkpiano is there a way you could open up the Inspector front end code?

Thanks again for this amazing tool!

@davidkpiano
Copy link

@davidkpiano is there a way you could open up the Inspector front end code?

Yep, I'm currently working on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants