mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-26 03:58:44 +00:00
hotfixes
This commit is contained in:
parent
08147fc33b
commit
bd23d3fbdb
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
## 0.38.20
|
## 0.38.20
|
||||||
|
|
||||||
|
* `BehaviourBuilder FSM`:
|
||||||
|
* Hotfixes
|
||||||
|
|
||||||
## 0.38.19
|
## 0.38.19
|
||||||
|
|
||||||
* `BehaviourBuilder`:
|
* `BehaviourBuilder`:
|
||||||
|
@ -28,7 +28,9 @@ interface BehaviourContextWithFSM<T : State> : BehaviourContext, StatesMachine<T
|
|||||||
handlers: List<BehaviourWithFSMStateHandlerHolder<*, T>>
|
handlers: List<BehaviourWithFSMStateHandlerHolder<*, T>>
|
||||||
): T? {
|
): T? {
|
||||||
return handlers.firstOrNull { it.checkHandleable(state) } ?.run {
|
return handlers.firstOrNull { it.checkHandleable(state) } ?.run {
|
||||||
handleState(contextUpdatesFlow, state)
|
doInSubContext(updatesUpstreamFlow = contextUpdatesFlow) {
|
||||||
|
handleState(state)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,21 +34,12 @@ class BehaviourWithFSMStateHandlerHolder<I : O, O : State>(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Handling of 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(
|
suspend fun BehaviourContextWithFSM<in O>.handleState(
|
||||||
contextUpdatesFlow: Flow<Update>,
|
|
||||||
state: O
|
state: O
|
||||||
): O? {
|
): O? = with(delegateTo) {
|
||||||
val subscope = scope.LinkedSupervisorScope()
|
|
||||||
return with(copy(scope = subscope, upstreamUpdatesFlow = contextUpdatesFlow)) {
|
|
||||||
with(delegateTo) {
|
|
||||||
handleState(state as I)
|
handleState(state as I)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fun <reified I : O, O : State> BehaviourWithFSMStateHandlerHolder(
|
inline fun <reified I : O, O : State> BehaviourWithFSMStateHandlerHolder(
|
||||||
|
Loading…
Reference in New Issue
Block a user