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

Ability to get vanilla XState JSON #76

Open
mahmoud opened this issue Oct 25, 2023 · 1 comment
Open

Ability to get vanilla XState JSON #76

mahmoud opened this issue Oct 25, 2023 · 1 comment

Comments

@mahmoud
Copy link
Contributor

mahmoud commented Oct 25, 2023

I have a bit of familiarity with XState, and while coming up to speed on xstate-wizards, I found it helpful to visualize/simulate the resulting XState state machine using stately.ai. Here's the xstate-react demo on stately.ai.

However, to get vanilla XState JSON I could import in stately, I had to hack a log line into packages/spells/src/machines/createSpell.ts (after the state prepper, before the createMachine call).

Can we refactor this (and/or create a utility function) to get the JSON-serializable object back? Would be good to be able to get back the state machine underlying any spell.

@youmustfight
Copy link
Member

youmustfight commented Oct 25, 2023

100% love this goal. Maybe the API for createSpell can shift a bit:

  • createMachineConfig could be a function on there for just getting back JSON. Basically takes all of the logic of the current createMachine method, but just doesn't do the create machine call as you pointed out.
  • createMachine is refactored to just call that function, ex: return createMachine(this.createMachineConfig())

And then that way createMachine continues to work as is.

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

No branches or pull requests

2 participants