mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-12-22 16:47:15 +00:00
commit
34fd9edce0
@ -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`:
|
||||
|
@ -12,7 +12,7 @@ import kotlinx.coroutines.*
|
||||
interface StatesMachine<T : State> : StatesHandler<T, T> {
|
||||
suspend fun launchStateHandling(
|
||||
state: T,
|
||||
handlers: List<CustomizableHandlerHolder<in T, T>>
|
||||
handlers: List<CheckableHandlerHolder<in T, T>>
|
||||
): T? {
|
||||
return handlers.firstOrNull { it.checkHandleable(state) } ?.run {
|
||||
handleState(state)
|
||||
@ -35,7 +35,7 @@ interface StatesMachine<T : State> : StatesHandler<T, T> {
|
||||
*/
|
||||
operator fun <T: State> invoke(
|
||||
statesManager: StatesManager<T>,
|
||||
handlers: List<CustomizableHandlerHolder<in T, T>>
|
||||
handlers: List<CheckableHandlerHolder<in T, T>>
|
||||
) = DefaultStatesMachine(statesManager, handlers)
|
||||
}
|
||||
}
|
||||
@ -46,7 +46,7 @@ interface StatesMachine<T : State> : StatesHandler<T, T> {
|
||||
*/
|
||||
class DefaultStatesMachine <T: State>(
|
||||
private val statesManager: StatesManager<T>,
|
||||
private val handlers: List<CustomizableHandlerHolder<in T, T>>
|
||||
private val handlers: List<CheckableHandlerHolder<in T, T>>
|
||||
) : StatesMachine<T> {
|
||||
/**
|
||||
* Will call [launchStateHandling] for state handling
|
||||
|
@ -9,14 +9,18 @@ class FSMBuilder<T : State>(
|
||||
var statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
||||
var defaultStateHandler: StatesHandler<T, T>? = StatesHandler { null }
|
||||
) {
|
||||
private var states = mutableListOf<CustomizableHandlerHolder<T, T>>()
|
||||
private var states = mutableListOf<CheckableHandlerHolder<T, T>>()
|
||||
|
||||
fun add(handler: CheckableHandlerHolder<T, T>) {
|
||||
states.add(handler)
|
||||
}
|
||||
|
||||
fun <I : T> add(kClass: KClass<I>, handler: StatesHandler<I, T>) {
|
||||
states.add(CheckableHandlerHolder(kClass, false, handler))
|
||||
add(CheckableHandlerHolder(kClass, false, handler))
|
||||
}
|
||||
|
||||
fun <I : T> add(filter: suspend (state: State) -> Boolean, handler: StatesHandler<I, T>) {
|
||||
states.add(handler.holder(filter))
|
||||
add(handler.holder(filter))
|
||||
}
|
||||
|
||||
fun <I : T> addStrict(kClass: KClass<I>, handler: StatesHandler<I, T>) {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user