From df4eaea4b9fd4e1da22af9a72e439d2b1e3cd54f Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 10 May 2021 19:24:21 +0600 Subject: [PATCH] doInDefault and doInIO --- CHANGELOG.md | 1 + .../main/kotlin/dev/inmo/micro_utils/coroutines/DoInUI.kt | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b826566561..7ae0d1cccfa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ * **ALL DEPRECATIONS WERE REMOVED** * `Coroutines`: * New extension and function `doSynchronously` which are the same as `launchSynchronously` + * New extensions `doInDefault` and `doInIO` ## 0.4.36 diff --git a/coroutines/src/main/kotlin/dev/inmo/micro_utils/coroutines/DoInUI.kt b/coroutines/src/main/kotlin/dev/inmo/micro_utils/coroutines/DoInUI.kt index f938e53655f..ab23e3f87d7 100644 --- a/coroutines/src/main/kotlin/dev/inmo/micro_utils/coroutines/DoInUI.kt +++ b/coroutines/src/main/kotlin/dev/inmo/micro_utils/coroutines/DoInUI.kt @@ -8,3 +8,11 @@ suspend inline fun doInUI(noinline block: suspend CoroutineScope.() -> T) = Dispatchers.Main, block ) +suspend inline fun doInDefault(noinline block: suspend CoroutineScope.() -> T) = withContext( + Dispatchers.Default, + block +) +suspend inline fun doInIO(noinline block: suspend CoroutineScope.() -> T) = withContext( + Dispatchers.IO, + block +)