-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Initial should accept deeply nested IDs #675
Comments
We'll have to take types into consideration if we decide to do this, as well as dev-time validation. For example, if there an |
No, if a state |
EDIT:// not sure if that was clear from my reply so I’ll try to explain more explicitly what I have meant. For initial specified as foo.bar the foo state is ofc entered as its ancestor of bar - so @mogsie is right about that. I was kinda fixated over initial transitions - they might be skipped. The relevant part of the spec:
|
👍 I was just responding to @davidkpiano's question about how to resolve it. It is indeed simple to resolve. The fact that an
But maybe that's a different issue? |
Yeah - you were right, I just had some other context in mind (I was looking into supporting
I'm looking into adding support for this with: {
initial: {
target: 'child_id',
actions
}
} Seems like a straightforward API, closely resembling what is specified by the SCXML spec. Just figuring out how to maintain correct execution order of those actions in combination with entry actions.
I've started to think that ideal two-way conversion is not possible as XState aims to be more strict in some regards, allowing some of the SCXML semantics only "on-demand" through existing, but non-default APIs/options. With such constraints, conversion from XState to SCXML might be lossy and converting ideally back to XState might not be possible (at least not easily).
Yes and no, for this to be solved we have to add support for deeply nested initial IDs (this issue) and for initial with actions (#466) |
@davidkpiano I just had this issue, where, when I try to use a nested state on the
The example state machine: createMachine({
id: 'myStateMachine',
initial: 'anotherState.default',
states: {
default: {},
anotherState: {
initial: 'nonDefaultSubState',
states: {
default: {},
nonDefaultSubState: {},
},
},
},
}) This issue was closed without any comment about why, it seems the issue is still present. Do you consider reopening or is this something which won't be fixed? |
@thomasaull could u describe ur use case for this feature? |
@Andarist In my case, I was trying to start a state machine in an arbitrary state, by stopping the interpreter, update the state machine |
Following for the similar use case. |
We've discussed this and determined that only child keys should be allowed for initial states, for both implementation simplicity and type safety. |
While reading SCXML spec I've noticed that it might be possible to specify deeply nested IDs for
initial
attribute (and<initial>
element) - it's not restricted to direct descendants.Those tests confirm this:
In addition to that - initial should support specifying multiple IDs (to target multiple deep parallel states). This can only be pursued after we add support for deep initials though.
The text was updated successfully, but these errors were encountered: