【发布时间】:2021-01-15 08:43:45
【问题描述】:
我想知道 Call 和 Response 之间的区别?在 Retrofit 中何时使用 Call 和何时使用 Response?
@GET("/albums/{id}")
suspend fun functionOne(@Path(value = "id") albumsId:Int):Response<Albums>
@GET("/albums/{id}")
suspend fun functionTwo(@Path(value = "id") albumsId:Int):Call<Albums>
这两个函数对我来说都很好,它们都有不同的实现,但用途几乎相同。
1.哪种响应类型适合最佳实践?
2。何时使用响应和呼叫?
【问题讨论】:
-
如果您查看它们各自的导入,那么 Response 和 Call 来自哪个库?是来自 Retrofit 还是 OkHttp?
标签: android android-studio kotlin retrofit2 kotlin-coroutines