From eb78f21eecd38b19f59e4eb6f6dfbe6e255a5fbc Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 26 Dec 2021 21:21:40 +0600 Subject: [PATCH] fix FSMBuilder --- .../inmo/micro_utils/fsm/common/dsl/FSMBuilder.kt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/fsm/common/src/commonMain/kotlin/dev/inmo/micro_utils/fsm/common/dsl/FSMBuilder.kt b/fsm/common/src/commonMain/kotlin/dev/inmo/micro_utils/fsm/common/dsl/FSMBuilder.kt index aa244eed616..d0378c88d0f 100644 --- a/fsm/common/src/commonMain/kotlin/dev/inmo/micro_utils/fsm/common/dsl/FSMBuilder.kt +++ b/fsm/common/src/commonMain/kotlin/dev/inmo/micro_utils/fsm/common/dsl/FSMBuilder.kt @@ -7,12 +7,10 @@ import kotlin.reflect.KClass class FSMBuilder( var statesManager: StatesManager = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()), - val fsmBuilder: (states: List>, defaultHandler: StatesHandler?) -> StatesMachine = { states, defaultHandler -> + val fsmBuilder: (states: List>, statesManager: StatesManager) -> StatesMachine = { states, statesManager -> StatesMachine( statesManager, - states.let { list -> - defaultHandler ?.let { list + it.holder { true } } ?: list - } + states ) }, var defaultStateHandler: StatesHandler? = StatesHandler { null } @@ -50,7 +48,12 @@ class FSMBuilder( add(filter, handler) } - fun build() = fsmBuilder(states.toList(), defaultStateHandler) + fun build() = fsmBuilder( + states.toList().let { list -> + defaultStateHandler ?.let { list + it.holder { true } } ?: list + }, + statesManager + ) } fun buildFSM(