KStateMachine / kstatemachine

KStateMachine is a powerful Kotlin Multiplatform library with clean DSL syntax for creating complex state machines and statecharts driven by Kotlin Coroutines.
https://kstatemachine.github.io/kstatemachine/
Boost Software License 1.0
358 stars 21 forks source link

Cound I apply an transition for all states at the same time ? #60

Closed xufeifeiWHU closed 1 year ago

xufeifeiWHU commented 1 year ago

Hi , sir it is a great job , when I try to apply it into project , I need to add a transition for all states , whatever the src state , I have tried several times ,but still could not add such transition .

for example :
A -> C -> D -> E -> F
and when a special event received, all the state need to jump to G 

I have  read the code in test case , but no inspiration on this point yet
Is there such a way that could add such transition now ?

thanls for your

nsk90 commented 1 year ago

Hi! thanks, yes it is possible. Use state hierarchy for that. Add a parent for your states, and put transition into it. If you don't need additional parent you can put transition into state machine itself. All child states will inherit this transition, and even can override it if necessary.

nsk90 commented 1 year ago

Please read "Nested states" section in docs https://nsk90.github.io/kstatemachine/

xufeifeiWHU commented 1 year ago

it really works thanks