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

Usage of Visualizer in other places #67

Open
ZempTime opened this issue May 14, 2020 · 6 comments
Open

Usage of Visualizer in other places #67

ZempTime opened this issue May 14, 2020 · 6 comments

Comments

@ZempTime
Copy link

ZempTime commented May 14, 2020

Description
I'm trying to use <StateChart> to render out various machines in our system, so business folks and devs can peek their heads in and see what's going on.

What I'm running into is:

Screen Shot 2020-05-14 at 4 20 01 PM

whch appears to be referencing this: https://github.com/statecharts/xstate-viz/blob/master/src/StateChartVisualization.tsx#L3

Afaik, xstate/lib/graph has been moved into @xstate/graph.

Additional context
I'm mounting it all inside a web component and then rendering this inside there (following altered to omit nonessential info so I can share publicly):

import { StateChart } from "@statecharts/xstate-viz";

const Visualizer: React.FC<any> = ({machine}) => {
  const onSave = (e) => {
    console.log(e)
  }
  return (
    <StateChart machine={machine} onSave={onSave}/>
  )
}
import React from "react";
import ReactDOM from "react-dom";
import Visualizer from "../components/visualizer";
import machine from "project/src/machine";

export default class PageProjectVisualizer extends HTMLElement {
  connectedCallback() {
    const mountPoint = document.createElement("span");
    this.attachShadow({ mode: "open" }).appendChild(mountPoint);

    ReactDOM.render(<Visualizer machine={machine} />, mountPoint);
  }
}
customElements.define("page-project-visualizer", PageProjectVisualizer);

Is this package intended to be used in this way? Is there another way of accomplishing this?

I'd be happy to help get this building and exporting esm's if you're open to it. This would go a long way towards xstate usage/adoption inside my company.

@davidkpiano
Copy link
Collaborator

There will be a ready-made component in the XState repository itself for this.

If you want to play around with it now, it's @xstate/viz 🕵️

It's not ready for release but if you're eager, you can look around and try to make it work locally!

@bwalsh
Copy link

bwalsh commented May 20, 2020

Tried starting @xstate/viz example. Use npm link, etc. No luck. No errors during build or start, but rendered blank page.
@davidkpiano ^

@davidkpiano
Copy link
Collaborator

@bwalsh

It's not ready for release but if you're eager, you can look around and try to make it work locally!

It's up to you right now to figure out how to make it work. Or you can wait until it's publicly released.

@hediet
Copy link

hediet commented Aug 31, 2020

I think this visualization would be an awesome addition for the debug visualizer extension for VS Code.

Sadly, the xstate visualizer is broken currently, otherwise I could easily integrate it!

@davidkpiano
Copy link
Collaborator

@hediet Check out the Keyframers stream at 5 PM today. I'll be releasing the works-anywhere visualizer soon.

@martinklepsch
Copy link

It seems that https://statecharts.io/ has examples of using a visualizer.

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

No branches or pull requests

5 participants