statemachine icon indicating copy to clipboard operation
statemachine copied to clipboard

How to transition directly to a specific state instead of triggering an event name

Open vanasis opened this issue 1 year ago • 1 comments

Hello,

I'm using the StateMachine library to handle state transitions, but I want to streamline the process by transitioning directly to a target state instead of firing an event name. Ideally, I would specify a target state (e.g., GoToState("Approved")), and the state machine would check if there’s a valid transition path from the current state to that target state. If the transition is allowed, it should proceed; if not, it should prevent the transition.

To summarize, I'm looking to:

Specify a target state directly instead of firing an event. Have the state machine validate if a transition to the target state exists before moving. Is there a way to configure StateMachine to support this state-based approach rather than relying on event names?

Thank you for any help!

vanasis avatar Oct 31 '24 08:10 vanasis

I don't know any way to achieve this in a simple way. It's against the principles that are at the design of this state machine: states are only known to the state machine, the outside can only observe the effects of transitions.

ursenzler avatar Nov 19 '24 09:11 ursenzler