appccelerate / statemachine

A .net library that lets you build state machines (hierarchical, async with fluent definition syntax and reporting capabilities).
Apache License 2.0
496 stars 129 forks source link

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

Open vanasis opened 3 weeks ago

vanasis commented 3 weeks ago

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!

ursenzler commented 4 days ago

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.