Correct way to use substatemachine #1015
Unanswered
damienmiheev
asked this question in
Q&A
Replies: 1 comment
-
Ok, thats because i put:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm not sure I clearly understand how to use substates. I didn't find any good explained example of correct spring state machine configuration, so I would be glad if somebody can share it we me.
On the picture below there is dummy representation of spring machine i'm currently working on (actual number of states is much bigger). Logically inner states may be grouped into 3 parent states: registration, user configuration and admin configuration.
Question #1. Is this correct usage of substates? I can write it without substates, but I feel like it may and should be grouped. Second picture is a diagram of SM from the spring docs and it looks pretty the same what i have in my own SM: https://docs.spring.io/spring-statemachine/docs/current/reference/index.html#configuring-hierarchical-states
Question #2. There is some output in logs I can't understand.
This is part of my transitions config:
And states config:
So ADMIN is a parent state, and initial state of this submachine is ADMIN_ROLE.
This is the logs of my SM execution:
I put breakpoints before sending event to state machine. And for the first BP, the result of statemachine.state.id was ADMIN - state that marked as parent. However, before that I see in logs we already entered into ADMIN_ROLE state. Ok, I understood this as state.id is a currentState of main SM. For breakpoint #2, result of statemachine.state.id was ADMIN_SMTH. So the question is, why in case 1 I see state of main state machine, and for case 2 the result is state of submachine? Maybe I did something wrong?
Beta Was this translation helpful? Give feedback.
All reactions