diff --git a/README.md b/README.md
index 65b32161..d06ebbbc 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@ English | [中文文档](https://github.com/liujingxing/rxhttp/blob/master/READM
A type-safe HTTP client for Android. Written based on OkHttp
-![sequence_chart_en.jpg](https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/2c637845930b49d7a7466ec7b5dcdb77~tplv-k3u1fbpfcp-watermark.image)
+![sequence_chart_en.jpg](https://p6-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/2e25f9c6aa694b57bd43871eff95cecd~tplv-k3u1fbpfcp-watermark.image)
@@ -26,13 +26,13 @@ A type-safe HTTP client for Android. Written based on OkHttp
//tryAwait return User?
val user = RxHttp.get("/server/..")
.add("key", "value")
- .toClass()
+ .toAwait()
.await()
//or awaitResult return kotlin.Result
RxHttp.get("/server/..")
.add("key", "value")
- .toClass()
+ .toAwait()
.awaitResult {
//Success
}.onFailure {
@@ -60,7 +60,7 @@ A type-safe HTTP client for Android. Written based on OkHttp
```java
RxHttp.get("/server/..")
.add("key", "value")
- .asClass()
+ .toObserable()
.subscribe({
//Success
}, {
@@ -74,7 +74,7 @@ A type-safe HTTP client for Android. Written based on OkHttp
```java
RxHttp.get("/server/..")
.add("key", "value")
- .asClass(User.class)
+ .toObserable(User.class)
.subscribe(user - > {
//Success
}, throwable -> {
@@ -135,18 +135,23 @@ android {
plugins {
// kapt/ksp choose one
// id 'kotlin-kapt'
- id 'com.google.devtools.ksp' version '1.7.10-1.0.6'
+ id 'com.google.devtools.ksp' version '1.7.20-1.0.7'
}
//Make IDE aware of generated code if you use ksp
-kotlin {
- sourceSets.debug {
- kotlin.srcDir("build/generated/ksp/debug/kotlin")
+android {
+ applicationVariants.all { variant ->
+ sourceSets {
+ def name = variant.name
+ getByName(name) { //告知IDE,ksp生成的kotlin代码
+ kotlin.srcDir("build/generated/ksp/$name/kotlin")
+ }
+ }
}
}
dependencies {
- def rxhttp_version = '2.9.5'
+ def rxhttp_version = '3.0.0'
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
implementation "com.github.liujingxing.rxhttp:rxhttp:$rxhttp_version"
// ksp/kapt/annotationProcessor choose one
@@ -284,7 +289,7 @@ This step is optional
```java
RxHttpPlugins.init(OkHttpClient)
.setDebug(boolean)
- .setOnParamAssembly(Function)
+ .setOnParamAssembly(Consumer)
....
```
@@ -308,7 +313,7 @@ public class Url {
RxHttp.get("/service/...") //1、You can choose get,postFrom,postJson etc
.addQuery("key", "value") //add query param
.addHeader("headerKey", "headerValue") //add request header
- .asClass(Student.class) //2、Use the asXxx method to determine the return value type, customizable
+ .toObserable(Student.class) //2、Use the asXxx method to determine the return value type, customizable
.subscribe(student -> { //3、Subscribing observer
//Success callback,Default IO thread
}, throwable -> {
@@ -320,7 +325,7 @@ RxHttp.postForm("/service/...") //post FormBody
.add("key", "value") //add param to body
.addQuery("key1", "value1") //add query param
.addFile("file", File(".../1.png")) //add file to body
- .asClass()
+ .toObserable()
.subscribe({ student ->
//Default IO thread
}, { throwable ->
@@ -329,7 +334,7 @@ RxHttp.postForm("/service/...") //post FormBody
// kotlin coroutine
val students = RxHttp.postJson("/service/...") //1、post {application/json; charset=utf-8}
- .toList() //2、Use the toXxx method to determine the return value type, customizable
+ .toAwaitList() //2、Use the toXxx method to determine the return value type, customizable
.await() //3、Get the return value, await is the suspend method
```
@@ -340,7 +345,7 @@ val students = RxHttp.postJson("/service/...") //1、post {application/json; ch
```java
//In Rxjava2 , Automatic close request
RxHttp.get("/service/...")
- .asString()
+ .toObservableString()
.as(RxLife.as(this)) //The Activity destroys and automatically closes the request
.subscribe(s -> {
//Default IO thread
@@ -350,7 +355,7 @@ RxHttp.get("/service/...")
//In Rxjava3 , Automatic close request
RxHttp.get("/service/...")
- .asString()
+ .toObservableString()
.to(RxLife.to(this)) //The Activity destroys and automatically closes the request
.subscribe(s -> {
//Default IO thread
@@ -361,7 +366,7 @@ RxHttp.get("/service/...")
//In RxJava2/RxJava3, close the request manually
Disposable disposable = RxHttp.get("/service/...")
- .asString()
+ .toObservableString()
.subscribe(s -> {
//Default IO thread
}, throwable -> {
diff --git a/README_zh.md b/README_zh.md
index f6a7d176..3e74fc41 100644
--- a/README_zh.md
+++ b/README_zh.md
@@ -33,10 +33,10 @@
# 2、请求三部曲
-![](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/96962077a7874293919bc8379b2d45ac~tplv-k3u1fbpfcp-watermark.image)
+![](https://p1-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/29bdab825c4f42c0983c58777f3af675~tplv-k3u1fbpfcp-watermark.image)
***代码表示,
-[asXxx、toXxx、toFlowXxx方法介绍点这里](https://github.com/liujingxing/rxhttp/wiki/RxJava%E3%80%81Await%E3%80%81Flow-%E5%AF%B9%E5%BA%94%E7%9A%84-asXxx%E3%80%81toXxx%E3%80%81toFlowXxx%E6%96%B9%E6%B3%95%E4%BB%8B%E7%BB%8D)***
+[toObservableXxx、toAwaitXxx、toFlowXxx方法介绍点这里](https://github.com/liujingxing/rxhttp/wiki/RxJava%E3%80%81Await%E3%80%81Flow-%E5%AF%B9%E5%BA%94%E7%9A%84-asXxx%E3%80%81toXxx%E3%80%81toFlowXxx%E6%96%B9%E6%B3%95%E4%BB%8B%E7%BB%8D)***
@@ -53,13 +53,13 @@
//同步式写法
val user = RxHttp.get("/server/..")
.add("key", "value")
- .toClass()
+ .toAwait()
.await() //tryAwait return User?
//回调式写法
RxHttp.get("/server/..")
.add("key", "value")
- .toClass()
+ .toAwait()
.awaitResult {
//成功回调
}.onFailure {
@@ -87,7 +87,7 @@
```java
RxHttp.get("/server/..")
.add("key", "value")
- .asClass()
+ .toObserable()
.subscribe({
//成功回调
}, {
@@ -101,7 +101,7 @@
```java
RxHttp.get("/server/..")
.add("key", "value")
- .asClass(User.class)
+ .toObserable(User.class)
.subscribe(user - > {
//成功回调
}, throwable -> {
@@ -118,13 +118,13 @@
| 功能说明 | RxHttp | [Retrofit](https://github.com/square/retrofit) |
| --- | :---: | :---: |
-| 版本| v2.9.5| v2.9.0 |
+| 版本| v3.0.0| v2.9.0 |
| 状态| 维护中| 维护中 |
| 标准RESTful风格| ✅ | ✅ |
| 学习成本| 低 | 高|
| 扩展性| 高| 高|
| 源码大小| 81k | 75k |
-| jar包大小| 269k | 123k |
+| jar包大小| 218k | 123k |
| RxJava| RxJava ❌
RxJava2✅
RxJava3✅| RxJava ✅
RxJava2✅
RxJava3✅|
| Kotlin协程| ✅ | ✅ |
| Flow流| ✅ | ✅ |
@@ -143,7 +143,7 @@
**说明**
-也许你有会有疑问,RxHttp源码大小仅比retrofit大6k的情况下,jar包大小为何会大一倍多?功能太多导致的代码臃肿?并不是,而是由kotlin导致的,在RxHttp内部,为了支持`Await/Flow`,运用了大量的kotlin内联方法及扩展方法,这些方法在编译为字节码后,都会相对较大,其中[AwaitTransform.kt](https://github.com/liujingxing/rxhttp/blob/master/rxhttp/src/main/java/rxhttp/AwaitTransform.kt)、[CallFactoryToAwait.kt](https://github.com/liujingxing/rxhttp/blob/master/rxhttp/src/main/java/rxhttp/CallFactoryToAwait.kt)、[CallFactoryToFlow.kt](https://github.com/liujingxing/rxhttp/blob/master/rxhttp/src/main/java/rxhttp/CallFactoryToFlow.kt)这3个kotlin文件,编译为字节码后,就达到了100k+, 再加上其他kotlin文件,就达到了目前的jar包大小
+也许你有会有疑问,RxHttp源码大小仅比retrofit大6k的情况下,jar包大小为何会大一倍多?功能太多导致的代码臃肿?并不是,而是由kotlin导致的,在RxHttp内部,为了支持`Await/Flow`,运用了大量的kotlin内联方法及扩展方法,这些方法在编译为字节码后,都会相对较大,其中[AwaitTransform.kt](https://github.com/liujingxing/rxhttp/blob/master/rxhttp/src/main/java/rxhttp/AwaitTransform.kt)、[CallFactoryToAwait.kt](https://github.com/liujingxing/rxhttp/blob/master/rxhttp/src/main/java/rxhttp/CallFactoryToAwait.kt)、[CallFactoryToFlow.kt](https://github.com/liujingxing/rxhttp/blob/master/rxhttp/src/main/java/rxhttp/CallFactoryToFlow.kt)这3个kotlin文件,编译为字节码后,就达到了100k+
# 3、相关文档
@@ -194,7 +194,7 @@ android {
}
//3、添加依赖
dependencies {
- def rxhttp_version = '2.9.5'
+ def rxhttp_version = '3.0.0'
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
implementation "com.github.liujingxing.rxhttp:rxhttp:$rxhttp_version"
annotationProcessor "com.github.liujingxing.rxhttp:rxhttp-compiler:$rxhttp_version"
@@ -226,7 +226,7 @@ plugins {
}
dependencies {
- def rxhttp_version = '2.9.5'
+ def rxhttp_version = '3.0.0'
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
implementation "com.github.liujingxing.rxhttp:rxhttp:$rxhttp_version"
kapt "com.github.liujingxing.rxhttp:rxhttp-compiler:$rxhttp_version"
@@ -263,11 +263,11 @@ android {
}
//3、添加插件及依赖
plugins {
- id 'com.google.devtools.ksp' version '1.7.10-1.0.6'
+ id 'com.google.devtools.ksp' version '1.7.20-1.0.7'
}
dependencies {
- def rxhttp_version = '2.9.5'
+ def rxhttp_version = '3.0.0'
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
implementation "com.github.liujingxing.rxhttp:rxhttp:$rxhttp_version"
ksp "com.github.liujingxing.rxhttp:rxhttp-compiler:$rxhttp_version"
diff --git a/app/build.gradle b/app/build.gradle
index 69f9787a..3a84da68 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -2,7 +2,7 @@ plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
- id 'com.google.devtools.ksp' version "$ksp_version"
+// id 'com.google.devtools.ksp' version "$ksp_version"
// id 'org.jetbrains.kotlin.plugin.serialization' version '1.7.10'
}
@@ -54,18 +54,18 @@ android {
}
}
-ksp {
- arg("rxhttp_rxjava", rxjava_version)
-// arg("rxhttp_package", "rxhttp")
-}
-
-//kapt {
-// arguments {
-// arg("rxhttp_rxjava", rxjava_version) //可传入rxjava2、rxjava3或具体版本号,如 3.1.1
-//// arg("rxhttp_package", "rxhttp") //设置RxHttp相关类的包名,多module依赖时,需要配置不同的包名
-// }
+//ksp {
+// arg("rxhttp_rxjava", rxjava_version)
+//// arg("rxhttp_package", "rxhttp")
//}
+kapt {
+ arguments {
+ arg("rxhttp_rxjava", rxjava_version) //可传入rxjava2、rxjava3或具体版本号,如 3.1.1
+// arg("rxhttp_package", "rxhttp") //设置RxHttp相关类的包名,多module依赖时,需要配置不同的包名
+ }
+}
+
//configurations.all {
// resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
@@ -85,8 +85,8 @@ dependencies {
implementation "androidx.lifecycle:lifecycle-service:$lifecycle_version"
implementation project(":rxhttp")
- ksp project(':rxhttp-compiler')
-// kapt project(':rxhttp-compiler')
+// ksp project(':rxhttp-compiler')
+ kapt project(':rxhttp-compiler')
// implementation "com.squareup.okhttp3:logging-interceptor:$okhttp_version"
implementation "com.squareup.okhttp3:okhttp:$okhttp_version"
diff --git a/gradle.properties b/gradle.properties
index 5ce09745..6c8bd866 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -20,7 +20,7 @@ org.gradle.jvmargs=-Xmx1536m
okhttp_version=4.10.0
rxjava_version=3.1.5
rxlife_version=2.2.2
-rxhttp_version=3.0.0-rc8
+rxhttp_version=3.0.0
lifecycle_version=2.5.0
ksp_version=1.7.20-1.0.7
diff --git a/maven_dependency.md b/maven_dependency.md
index 4d86b01f..9efa69cf 100644
--- a/maven_dependency.md
+++ b/maven_dependency.md
@@ -16,7 +16,7 @@
com.github.liujingxing.rxhttp
rxhttp
- 2.9.5
+ 3.0.0
@@ -48,7 +48,7 @@
com.github.liujingxing.rxhttp
rxhttp-compiler
- 2.9.5
+ 3.0.0