gpt4 book ai didi

android - anko bg 的替代品是什么?

转载 作者:行者123 更新时间:2023-11-29 18:31:17 28 4
gpt4 key购买 nike

我正在使用 anko bg 功能来管理后台任务。

代码如下

import com.github.kittinunf.fuel.core.FuelError
import com.github.kittinunf.fuel.core.Request
import com.github.kittinunf.fuel.core.Response
import com.github.kittinunf.result.Result
import org.jetbrains.anko.coroutines.experimental.bg

object AuthenticationService {
suspend fun login(login: Login): Triple<Request, Response, Result<GenResponse, FuelError>> {
return bg {
HttpService.post<GenResponse>("/auth/login",login.toJsonString())
}.await()
}
}

它显示 bg 已被弃用并要求我使用 async(block)

如何用异步替换这个后台任务?

最佳答案

考虑为不同类型的后台任务创建您自己的 ThreadPoolExecutor,并将它们用作协程调度程序。

而且你总是可以看看Anko bg source code供引用。

关于android - anko bg 的替代品是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56142234/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com