1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 08:13:47 +00:00

small improvement in BehaviourContext

This commit is contained in:
InsanusMokrassar 2024-06-14 19:54:06 +06:00
parent 86bd5eaa07
commit 60fdbb8ac4

View File

@ -132,6 +132,8 @@ fun <BC : BehaviourContext> BC.createSubContext(
/** /**
* Launch [behaviourContextReceiver] in context of [this] as [BehaviourContext] and as [kotlin.coroutines.CoroutineContext] * Launch [behaviourContextReceiver] in context of [this] as [BehaviourContext] and as [kotlin.coroutines.CoroutineContext]
*
* [this] [BehaviourContext] will **NOT** be closed automatically
*/ */
suspend fun <T, BC : BehaviourContext> BC.doInContext( suspend fun <T, BC : BehaviourContext> BC.doInContext(
behaviourContextReceiver: CustomBehaviourContextReceiver<BC, T> behaviourContextReceiver: CustomBehaviourContextReceiver<BC, T>
@ -152,12 +154,10 @@ suspend fun <T, BC : BehaviourContext> BC.createSubContextAndDoWithUpdatesFilter
): T { ): T {
return supervisorScope { return supervisorScope {
createSubContext( createSubContext(
scope = this, scope = this@supervisorScope,
triggersHolder = triggersHolder, triggersHolder = triggersHolder,
updatesUpstreamFlow = updatesUpstreamFlow updatesUpstreamFlow = updatesUpstreamFlow
).doInContext( ).behaviourContextReceiver()
behaviourContextReceiver = behaviourContextReceiver
)
} }
} }