Retrofit2+Kolin协程

robert70385 2 0 PDF 2021-01-10 21:01:49

Retrofit2.6开始增加了对Kotlin协程的支持,可以通过suspend函数进行异步调用。本文简单介绍一下Retrofit中协程的使用 data class 首先定义一个data class 模拟Api请求的response data class Repos( val id: Int, val name: String ) Retrofit 创建Retrofit实例 class ApiService { private fun getRetrofit(): Retrofit { val moshi = Moshi.Builder()

用户评论
请输入评论内容
评分:
暂无评论