aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2019-06-13 14:12:07 -0700
committerAllan Wang <me@allanwang.ca>2019-06-13 14:12:07 -0700
commit20e7919f0b14ee21107f14933a05e2e20e00780b (patch)
treeed48070fc1f21bc2ff8e0edf55305eb4741c8764 /core/src/main/kotlin
parenta3589553aa19e570f5df34c143afd5dead32e9ef (diff)
downloadkau-20e7919f0b14ee21107f14933a05e2e20e00780b.tar.gz
kau-20e7919f0b14ee21107f14933a05e2e20e00780b.tar.bz2
kau-20e7919f0b14ee21107f14933a05e2e20e00780b.zip
Open ctxCoroutine
Diffstat (limited to 'core/src/main/kotlin')
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/utils/CoroutineUtils.kt5
1 files changed, 3 insertions, 2 deletions
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
/**