I have a state machine with 4 states, (A,B,C and DONE). Since I am trying to set up a system can be resumed after interruption, each state is intentionally "stateless" and is passed all the information it needs via its payload.
- A will prepend to the plan a transition to B on an event, providing a list and an index of 0 as payload;
- C will also prepend to the plan a transition to B on an event, providing a different list and an index of 0 as its payload;
- B will process the item at position (index in the list. It will then add to the plan a transition to process the next (index + 1) item in the list. If there are no more items to process, it will transition to DONE.
- DONE will simply succeed, proceeding to the next item in the plan;
The transition A -> B or C -> B can occur at any time via an event.
For example my plan stack throughout multiple updates might look like:
- A -> B (index = 0, list of 100 items)
-- UPDATE --
B -> B (index = 1, list of 100 items)
-- UPDATE --
B -> B (index = 2, list of 100 items)
-- Event C --
C-> B (index = 0, list of 250 items)
B -> B (index = 2, list of 100 items)
-- UPDATE --
B -> B (index = 0, list of 250 items)
B -> B (index = 2, list of 100 items)
However, since both states on the stack have the same origin, the library drops the first and automatically transitions to the second.
Is this intentional or am I misusing the library? Is there a better way to achieve what I am going for?
I have a state machine with 4 states, (A,B,C and DONE). Since I am trying to set up a system can be resumed after interruption, each state is intentionally "stateless" and is passed all the information it needs via its payload.
The transition A -> B or C -> B can occur at any time via an event.
For example my plan stack throughout multiple updates might look like:
-- UPDATE --
B -> B (index = 1, list of 100 items)
-- UPDATE --
B -> B (index = 2, list of 100 items)
-- Event C --
C-> B (index = 0, list of 250 items)
B -> B (index = 2, list of 100 items)
-- UPDATE --
B -> B (index = 0, list of 250 items)
B -> B (index = 2, list of 100 items)
However, since both states on the stack have the same origin, the library drops the first and automatically transitions to the second.
Is this intentional or am I misusing the library? Is there a better way to achieve what I am going for?