Simplify EventChannel.parentScope

This commit is contained in:
Him188 2021-02-03 20:22:56 +08:00
parent 1205d95186
commit 3b06df6bc5

View File

@ -266,11 +266,7 @@ public open class EventChannel<out BaseEvent : Event> @JvmOverloads internal con
* @see CoroutineScope.globalEventChannel `GlobalEventChannel.parentScope()` 的扩展
*/
public fun parentScope(coroutineScope: CoroutineScope): EventChannel<BaseEvent> {
return context(coroutineScope.coroutineContext).run {
val job = coroutineScope.coroutineContext[Job]
if (job != null) parentJob(job)
else this
}
return context(coroutineScope.coroutineContext)
}
/**