1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2025-12-10 16:26:36 +00:00

Compare commits

..

3 Commits

Author SHA1 Message Date
bd23d3fbdb hotfixes 2022-05-03 23:12:03 +06:00
08147fc33b start 0.38.20 2022-05-03 23:11:02 +06:00
ba4c153659 Merge pull request #579 from InsanusMokrassar/0.38.19
0.38.19
2022-05-03 14:36:22 +06:00
4 changed files with 11 additions and 13 deletions

View File

@@ -1,5 +1,10 @@
# TelegramBotAPI changelog
## 0.38.20
* `BehaviourBuilder FSM`:
* Hotfixes
## 0.38.19
* `BehaviourBuilder`:

View File

@@ -20,6 +20,6 @@ javax_activation_version=1.1.1
dokka_version=1.6.10
library_group=dev.inmo
library_version=0.38.19
library_version=0.38.20
github_release_plugin_version=2.3.7

View File

@@ -28,7 +28,9 @@ interface BehaviourContextWithFSM<T : State> : BehaviourContext, StatesMachine<T
handlers: List<BehaviourWithFSMStateHandlerHolder<*, T>>
): T? {
return handlers.firstOrNull { it.checkHandleable(state) } ?.run {
handleState(contextUpdatesFlow, state)
doInSubContext(updatesUpstreamFlow = contextUpdatesFlow) {
handleState(state)
}
}
}

View File

@@ -34,20 +34,11 @@ class BehaviourWithFSMStateHandlerHolder<I : O, O : State>(
/**
* Handling of state :)
*
* @param contextUpdatesFlow This [Flow] will be used as source of updates. By contract, this [Flow] must be common
* for all [State]s of incoming [state] [State.context] and for the whole chain inside of [BehaviourContextWithFSM]
*/
suspend fun BehaviourContextWithFSM<in O>.handleState(
contextUpdatesFlow: Flow<Update>,
state: O
): O? {
val subscope = scope.LinkedSupervisorScope()
return with(copy(scope = subscope, upstreamUpdatesFlow = contextUpdatesFlow)) {
with(delegateTo) {
handleState(state as I)
}
}
): O? = with(delegateTo) {
handleState(state as I)
}
}