From 20e7919f0b14ee21107f14933a05e2e20e00780b Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Thu, 13 Jun 2019 14:12:07 -0700 Subject: Open ctxCoroutine --- core/src/main/kotlin/ca/allanwang/kau/utils/CoroutineUtils.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'core/src/main/kotlin/ca/allanwang/kau/utils/CoroutineUtils.kt') diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/CoroutineUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/CoroutineUtils.kt index 57a9921..4d6ee54 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/CoroutineUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/CoroutineUtils.kt @@ -18,6 +18,7 @@ package ca.allanwang.kau.utils import android.content.Context import android.os.Handler import android.os.Looper +import ca.allanwang.kau.internal.KauBaseActivity import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineStart import kotlinx.coroutines.android.asCoroutineDispatcher @@ -43,11 +44,11 @@ object ContextHelper : CoroutineScope { } /** - * Most context items implement [CoroutineScope] by default. + * Most context items implement [CoroutineScope] by default (through [KauBaseActivity]). * We will add a fallback just in case. * It is expected that the scope returned always has the Android main dispatcher as part of the context. */ -internal inline val Context.ctxCoroutine: CoroutineScope +inline val Context.ctxCoroutine: CoroutineScope get() = this as? CoroutineScope ?: ContextHelper /** -- cgit v1.2.3