From 86ff7b22ed4f60c3365c28d5a38be2e5d5d15386 Mon Sep 17 00:00:00 2001 From: Junerver Date: Thu, 14 Mar 2024 15:50:14 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=A9:=20remove=20meaningless=20coroutin?= =?UTF-8?q?e=20context=20switching?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xyz/junerver/composehooks/example/request/Auto&Manual.kt | 2 +- .../main/kotlin/xyz/junerver/compose/hooks/userequest/Fetch.kt | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/xyz/junerver/composehooks/example/request/Auto&Manual.kt b/app/src/main/java/xyz/junerver/composehooks/example/request/Auto&Manual.kt index 5ae3bc19..c533d7fa 100644 --- a/app/src/main/java/xyz/junerver/composehooks/example/request/Auto&Manual.kt +++ b/app/src/main/java/xyz/junerver/composehooks/example/request/Auto&Manual.kt @@ -96,7 +96,7 @@ fun Manual() { */ request() } - TButton(text = "request with params") { + TButton(text = "request with error params") { request("unknow", "unknow") } } diff --git a/hooks/src/main/kotlin/xyz/junerver/compose/hooks/userequest/Fetch.kt b/hooks/src/main/kotlin/xyz/junerver/compose/hooks/userequest/Fetch.kt index 158da259..25d944ba 100644 --- a/hooks/src/main/kotlin/xyz/junerver/compose/hooks/userequest/Fetch.kt +++ b/hooks/src/main/kotlin/xyz/junerver/compose/hooks/userequest/Fetch.kt @@ -5,7 +5,6 @@ import java.io.Serializable import kotlin.properties.Delegates import kotlin.reflect.KFunction import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.async @@ -191,7 +190,7 @@ class Fetch(private val options: RequestOptions = defaultOpt * 使用自身作用域的同步请求函数 */ override fun _run(params: TParams) { - this.scope.launch(Dispatchers.IO + SupervisorJob()) { + this.scope.launch { _runAsync(params) }.also { requestJobs.add(it) } }