diff --git a/CHANGELOG.md b/CHANGELOG.md index e223d0ed530..92b7a675688 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 0.8.2 + +* `Versions`: + * `Klock`: `2.4.7` -> `2.4.8` + * `Serialization`: `1.3.0` -> `1.3.1` +* `FSM`: + * Now it is possible to pass any `CheckableHandlerHolder` in `FSMBuilder` + * Now `StatesMachine` works with `CheckableHandlerHolder` instead of `CustomizableHandlerHolder` + ## 0.8.1 * `Versions`: diff --git a/fsm/common/src/commonMain/kotlin/dev/inmo/micro_utils/fsm/common/StatesMachine.kt b/fsm/common/src/commonMain/kotlin/dev/inmo/micro_utils/fsm/common/StatesMachine.kt index f31e641a3b0..d470ff12d5c 100644 --- a/fsm/common/src/commonMain/kotlin/dev/inmo/micro_utils/fsm/common/StatesMachine.kt +++ b/fsm/common/src/commonMain/kotlin/dev/inmo/micro_utils/fsm/common/StatesMachine.kt @@ -12,7 +12,7 @@ import kotlinx.coroutines.* interface StatesMachine : StatesHandler { suspend fun launchStateHandling( state: T, - handlers: List> + handlers: List> ): T? { return handlers.firstOrNull { it.checkHandleable(state) } ?.run { handleState(state) @@ -35,7 +35,7 @@ interface StatesMachine : StatesHandler { */ operator fun invoke( statesManager: StatesManager, - handlers: List> + handlers: List> ) = DefaultStatesMachine(statesManager, handlers) } } @@ -46,7 +46,7 @@ interface StatesMachine : StatesHandler { */ class DefaultStatesMachine ( private val statesManager: StatesManager, - private val handlers: List> + private val handlers: List> ) : StatesMachine { /** * Will call [launchStateHandling] for state handling 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 5713883f3f5..76786ecac6f 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 @@ -9,14 +9,18 @@ class FSMBuilder( var statesManager: StatesManager = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()), var defaultStateHandler: StatesHandler? = StatesHandler { null } ) { - private var states = mutableListOf>() + private var states = mutableListOf>() + + fun add(handler: CheckableHandlerHolder) { + states.add(handler) + } fun add(kClass: KClass, handler: StatesHandler) { - states.add(CheckableHandlerHolder(kClass, false, handler)) + add(CheckableHandlerHolder(kClass, false, handler)) } fun add(filter: suspend (state: State) -> Boolean, handler: StatesHandler) { - states.add(handler.holder(filter)) + add(handler.holder(filter)) } fun addStrict(kClass: KClass, handler: StatesHandler) { diff --git a/gradle.properties b/gradle.properties index ee3c1da5694..b4e09144229 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,12 +9,12 @@ org.gradle.jvmargs=-Xmx2g kotlin_version=1.5.31 kotlin_coroutines_version=1.5.2 -kotlin_serialisation_core_version=1.3.0 +kotlin_serialisation_core_version=1.3.1 kotlin_exposed_version=0.36.2 ktor_version=1.6.5 -klockVersion=2.4.7 +klockVersion=2.4.8 github_release_plugin_version=2.2.12 @@ -45,5 +45,5 @@ dokka_version=1.5.31 # Project data group=dev.inmo -version=0.8.1 -android_code_version=81 +version=0.8.2 +android_code_version=82