Android-Retrofit返回Flow

retrofit-adapter-flow

Retrofit 返回 Flow

Gradle 依赖

1.root build.gradle

allprojects {
	repositories {
		...
		maven { url "https://jitpack.io" }
	}
}

2.app build.gradle

dependencies {
	implementation 'com.github.chenxyu:retrofit-adapter-flow:$version'
}

使用方法

@POST(API.LOGIN)
fun login(@Body any: Any): Flow<User>

Retrofit.Builder()
    ...
    .addCallAdapterFactory(FlowCallAdapterFactory())
    .build()

你可能感兴趣的:(Android)