-
-
Notifications
You must be signed in to change notification settings - Fork 458
RxJava、Await、Flow 对应的 toObservableXxx、toAwaitXxx、toFlowXxx方法介绍
方法说明 | Await | Flow | RxJava (Java) |
RxJava (kotlin) |
---|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RxHttp.get("/server/...")
.toAwait<User>()
.toAwaitOkResponse()
.awaitResult {
val user = it.body()
val response = it.raw()
val headers = it.headers()
} |
RxHttp.get("/server/...")
.toFlow<User>()
.toFlowOkResponse()
.collect {
val user = it.body()
val response = it.raw()
val headers = it.headers()
} |
RxHttp.get("/server/...")
.toObservable(User.class)
.toObservableOkResponse()
.subscribe(res -> {
User user = res.body()
Response response = res.raw()
Headers headers = res.headers()
}); |
RxHttp.get("/server/...")
.toObservable<User>()
.toObservableOkResponse()
.subscribe {
val user = it.body()
val response = it.raw()
val headers = it.headers()
} |
|
//普通下载
RxHttp.get("/server/...")
.toDownloadAwait("本地绝对路径")
...
//断点下载
RxHttp.get("/server/...")
.toDownloadAwait("本地绝对路径", true)
...
//如需监听进度,请使用Flow实现 |
//普通下载
RxHttp.get("/server/...")
.toDownloadFlow("本地绝对路径")
.onProgress {
//下载进度回调
}
...
//断点下载
RxHttp.get("/server/...")
.toDownloadFlow("本地绝对路径", true)
.onProgress {
//下载进度回调
}
... |
//普通下载
RxHttp.get("/server/...")
.toDownloadObservable("本地绝对路径")
.onMainProgress(p -> {
//下载进度回调,亦可调用onProgress方法
})
...
//断点下载
RxHttp.get("/server/...")
.toDownloadObservable("本地绝对路径", true)
.onMainProgress(p -> {
//下载进度回调,亦可调用onProgress方法
})
... |
//普通下载
RxHttp.get("/server/...")
.toDownloadObservable("本地绝对路径")
.onMainProgress {
//下载进度回调,亦可调用onProgress方法
}
...
//断点下载
RxHttp.get("/server/...")
.toDownloadObservable("本地绝对路径", true)
.onMainProgress {
//下载进度回调,亦可调用onProgress方法
}
... |
|
//断点下载,普通下载第3个参数不传即可
toDownloadAwait(Context, Uri, true)
//如需监听下载进度,请使用Flow实现 |
//断点下载,普通下载第3个参数不传即可
toDownloadFlow(Context, Uri, true)
.onProgress {
//进度回调
} |
//断点下载,普通下载第3个参数不传即可
toDownloadObservable(Context, Uri, true)
.onMainProgress(p -> {
//下载进度回调,亦可调用onProgress方法
}) |
//断点下载,普通下载第3个参数不传即可
toDownloadObservable(Context, Uri, true)
.onMainProgress {
//下载进度回调,亦可调用onProgress方法
} |
|
|
RxHttp.postXxx("")
.toFlow<T>()
.onProgress {
//上传进度回调
}
... |
RxHttp.postXxx("")
.toObservableXxx(T.class)
.onMainProgress(p -> {
//下载进度回调,亦可调用onProgress方法
})
... |
RxHttp.postXxx("")
.toObservableXxx<T>()
.onMainProgress {
//下载进度回调,亦可调用onProgress方法
}
... |
方法说明 | Await | Flow | RxJava (Java) |
RxJava (kotlin) |
---|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|||
|
//不推荐,推荐Flow性能更优
RxHttp.postXxx("")
.upload(CoroutineScope) {
//进度回调
}
.toXxx()
... |
RxHttp.postXxx("")
.toFlow<T> {
//进度回调
}
... |
RxHttp.postXxx("")
.upload(progress -> {
//进度回调
})
.asXxx()
... |
RxHttp.postXxx("")
.upload {
//进度回调
}
.asXxx()
... |