mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-10 02:20:14 +08:00
Simplify EventChannel.parentScope
This commit is contained in:
parent
1205d95186
commit
3b06df6bc5
@ -266,11 +266,7 @@ public open class EventChannel<out BaseEvent : Event> @JvmOverloads internal con
|
|||||||
* @see CoroutineScope.globalEventChannel `GlobalEventChannel.parentScope()` 的扩展
|
* @see CoroutineScope.globalEventChannel `GlobalEventChannel.parentScope()` 的扩展
|
||||||
*/
|
*/
|
||||||
public fun parentScope(coroutineScope: CoroutineScope): EventChannel<BaseEvent> {
|
public fun parentScope(coroutineScope: CoroutineScope): EventChannel<BaseEvent> {
|
||||||
return context(coroutineScope.coroutineContext).run {
|
return context(coroutineScope.coroutineContext)
|
||||||
val job = coroutineScope.coroutineContext[Job]
|
|
||||||
if (job != null) parentJob(job)
|
|
||||||
else this
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user