Closed nsk90 closed 3 years ago
How do i get the current state from a machine object?
1) you can listen to per-state notifications https://github.com/nsk90/kstatemachine/blob/master/kstatemachine/src/main/kotlin/ru/nsk/kstatemachine/IState.kt#L38
2) you can listen to machine notification about all state changes https://github.com/nsk90/kstatemachine/blob/master/kstatemachine/src/main/kotlin/ru/nsk/kstatemachine/StateMachine.kt#L54
3) you can get current active states with activeStates() function. For machines with flat structure it will return single element list, for hierarchical machines there might be many active states at the same time. https://github.com/nsk90/kstatemachine/blob/master/kstatemachine/src/main/kotlin/ru/nsk/kstatemachine/IState.kt#L33
thank you
For example if UI attaches to statemachine that is already running. UI should know its current state, to be able to draw it.