Skip to content

Commit 620d313

Browse files
committed
[docs] Refactoring DataState docs
1 parent ac9e7eb commit 620d313

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

docs/index.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -565,22 +565,22 @@ createStateMachine {
565565
}
566566
```
567567
568-
`DataState`'s `data` field is set and might be accessed only while the state is active. When `DataState` is activated it
569-
requires data value from a `DataEvent`. You can use `lastData` field to access data after state exit, it falls back
568+
`DataState`'s `data` field is set and might be accessed only while the state is active. At the moment when `DataState`
569+
is activated it requires data value from a `DataEvent`. You can use `lastData` field to access last data value even after state exit, it falls back
570570
to `defaultData` if provided or throws.
571571

572572
### Corner cases of `DataState` activation
573573

574574
1. Implicit activation. `DataState` might be activated by `Event` (not `DataEvent`) that is targeting its child state.
575-
In this case `data` field of `DataState` is assigned by `lastData` field.
575+
In this case `data` field of `DataState` is assigned with `lastData` field value.
576576
If state is activating the first time `lastData` falls back to `defaultData` if provided, otherwise exception is
577577
thrown.
578-
2. Activation by `undo()` of `UndoEvent`. This works same way as for transition that was undone.
578+
2. Activation by `undo()` of `UndoEvent`. This works same way as undone transition.
579579
3. Activation by `FinishedEvent`. `FinishedEvent` may contain non-null data field. `DataState` receives this data
580580
if its type matches. `DataExtractor` class is responsible for matching. Such transition might be created only by
581581
`transitionConditionally()` function.
582-
4. Activation by non data event. This should not be necessary, but it might be done same way as in case 3. Using
583-
custom `DataExtractor` you can pass any data from any event type to `DataState`.
582+
4. Activation by non data event. This should not be necessary, but it might be done manually, same way as in case 3.
583+
Using custom `DataExtractor` you can pass any data from any event type to `DataState`.
584584

585585
## Arguments
586586

kstatemachine/src/main/kotlin/ru/nsk/kstatemachine/DataExtractor.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ package ru.nsk.kstatemachine
22

33
/**
44
* Allows to extract data for [DataState] from any [Event]
5+
*
6+
* [FinishedEvent] handling is separated into special method as it is very easy to forget to handle it in single method
7+
* when implementing custom [DataExtractor].
58
*/
69
interface DataExtractor<D : Any> {
710
fun extractFinishedEvent(transitionParams: TransitionParams<*>, event: FinishedEvent): D?

0 commit comments

Comments
 (0)