-
Notifications
You must be signed in to change notification settings - Fork 45
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
Allow the same state name in different parallel machines #17
Comments
@karl Thanks for interest in state-machine-cat, and for raising this issue. It'll probably make state-machine-cat a little better... I think your possible suggestion is the way to go; separating name and displayName (or
Implementation wise I would propose to slap the displayName (
The json would then look something like this: {
"states": [{
"name": "unset",
"label": "alarm not set",
"type": "regular"
}, {
"name": "set",
"label": "alarm set",
"type": "regular",
"activities": "show a bell"
}],
"transitions": [{
"from": "unset",
"to": "set",
"label": "enter time",
"event": "enter time"
}]
} In scjson/ scxml we can put the label into the ...
<state id="unset" name="alarm not set">
<transition event="enter_time" target="set"/>
</state>
... |
That all sounds great! Let me know if there is anything I can do to help out with this. |
@karl thanks for the offer! If you could give the new version a try and supply feedback (like you did with #15) that'd be massively helpful. Version
|
I'm very happy to test this and supply feedback. I should have time to look at it tomorrow. Thanks for the quick turnaround on this! |
Thanks @karl both for requesting this feature and for trying the beta The PR is merged and released a new major version of state-machine-cat. No worries; the version bump is major because I had to make a small breaking change in the syntax to introduce the label attribute - see the release notes for details). |
When creating parallel machines, every state must have a unique name.
For example:
I'd like to be able to have the states just be named
on
andoff
.Expected Behavior/Possible Solution
I wonder if when using the
json
representation of the state machine we could have the idea of states having something like adisplayName
that when provided is used for rendering the state name.This would allow me to use the current
name
field as a unique id, withdisplayName
giving a nice compact output.Context
I'm working on a library to convert
xstate
state chart descriptions in svg diagrams usingstate-machine-cat
.With
xstate
you can re-use the same state name across each part of a parallel or nested state machine. I'd like to be able to preserve these state names in the diagram output fromstate-machine-cat
.The text was updated successfully, but these errors were encountered: