Retrofit
返回 Flow<out T>
Dependency | Version |
---|---|
kotlin | 1.4.0 |
kotlinx-coroutines-android | 1.3.9 |
retrofit | 2.9.0 |
1.root build.gradle
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
2.app build.gradle
dependencies {
implementation 'com.github.chenxyu:retrofit-adapter-flow:1.1.0'
}
@POST(API.LOGIN)
fun login(@Body any: Any): Flow<User>
Retrofit.Builder()
...
.addCallAdapterFactory(FlowCallAdapterFactory())
.build()