Skip to content

Commit 49a126a

Browse files
committed
Add choice state logging
1 parent 78f3db8 commit 49a126a

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ open class DefaultFinalDataState<out D>(name: String? = null) : DefaultDataState
4545
open class DefaultChoiceState(name: String? = null, private val choiceAction: EventAndArgument<*>.() -> State) :
4646
BasePseudoState(name), RedirectPseudoState {
4747

48-
override fun resolveTargetState(eventAndArgument: EventAndArgument<*>) = eventAndArgument.choiceAction()
48+
override fun resolveTargetState(eventAndArgument: EventAndArgument<*>) =
49+
eventAndArgument.choiceAction().also { machine.log { "$this resolved to $it" } }
4950
}
5051

5152
open class BasePseudoState(name: String?) : BaseStateImpl(name, ChildMode.EXCLUSIVE), PseudoState {

kstatemachine/src/test/kotlin/ru/nsk/kstatemachine/ChoiceStateTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class ChoiceStateTest : StringSpec({
3232
val callbacks = mockkCallbacks()
3333

3434
val machine = createStateMachine {
35+
logger = StateMachine.Logger { println(it) }
36+
3537
val choice2 = choiceState("choice2") { State2 }
3638
val choice1 = choiceState("choice1") { choice2 }
3739

0 commit comments

Comments
 (0)