File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
kstatemachine/src/main/kotlin/ru/nsk/kstatemachine Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -412,6 +412,28 @@ choiceState {
412
412
}
413
413
```
414
414
415
+ ### History states
416
+
417
+ There are two types of history states, shallow and deep. Shallow history state is used to represent the most recently
418
+ active child (its neighbour) of a parent state. It does not recurse into this child's active configuration (sub states),
419
+ initial states will be used. Deep history state in contrast reflects the most recent active configuration of the parent
420
+ state (including all sub states).
421
+ You can specify default state which will be used if history was not recorded yet (parent was not active).
422
+ When default state is not specified, parent initial state will be entered on transition to history state.
423
+
424
+ ``` kotlin
425
+ val machine = createStateMachine {
426
+ state {
427
+ val state11 = initialState()
428
+ val state12 = state()
429
+ historyState(defultState = state12)
430
+ }
431
+ state {
432
+ // ...
433
+ }
434
+ }
435
+ ```
436
+
415
437
## Typesafe transitions
416
438
417
439
It is a common case when a state expects to receive some data from an event. Library provides typesafe API for such
Original file line number Diff line number Diff line change @@ -6,4 +6,7 @@ object Testing {
6
6
*/
7
7
fun StateMachine.startFrom (state : IState , argument : Any? = null) =
8
8
(this as InternalStateMachine ).startFrom(state, argument)
9
+
10
+ fun StateMachine.startFrom (stateName : String , argument : Any? = null) =
11
+ startFrom(requireState(stateName), argument)
9
12
}
You can’t perform that action at this time.
0 commit comments