-
Notifications
You must be signed in to change notification settings - Fork 500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RxJava3 support #685
base: main
Are you sure you want to change the base?
RxJava3 support #685
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Mavericks + RxJava3 | ||
|
||
[//]: # (TODO refine the documentation) | ||
|
||
MvRx 1.x was designed to work well with RxJava 2. | ||
|
||
However, Mavericks now uses coroutines internally. | ||
|
||
RxJava 3 compatibility is available via the `mavericks-rxjava3` artifact. | ||
|
||
To use it, use `BaseMvRxViewModel` instead of `MavericksViewModel`. Doing so will give you access to `execute` extensions on `Single<T>` and `Observable<T>` as well as all other MvRx 1.x APIs. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ activity = "androidx.activity:activity:_" | |
activityCompose = "androidx.activity:activity-compose:_" | ||
appcompat = "androidx.appcompat:appcompat:_" | ||
cardview = "androidx.cardview:cardview:_" | ||
material = "com.google.android.material:material:_" | ||
constraintlayout = "androidx.constraintlayout:constraintlayout:_" | ||
coordinatorLayout = "androidx.coordinatorlayout:coordinatorlayout:_" | ||
coreKtx = "androidx.core:core-ktx:_" | ||
|
@@ -59,12 +60,17 @@ picasso = "com.squareup.picasso:picasso:_" | |
recyclerview = "androidx.recyclerview:recyclerview:_" | ||
retrofit = "com.squareup.retrofit2:retrofit:_" | ||
retrofitMoshi = "com.squareup.retrofit2:converter-moshi:_" | ||
retrofitRxJava = "com.squareup.retrofit2:adapter-rxjava2:_" | ||
retrofitRxJava2 = "com.squareup.retrofit2:adapter-rxjava2:_" | ||
retrofitRxJava3 = "com.squareup.retrofit2:adapter-rxjava3:_" | ||
coil = "io.coil-kt:coil:_" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why add coil? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this one I added as part of rxjava demo, which is still in progress |
||
|
||
roomRuntime = "androidx.room:room-runtime:_" | ||
roomRxJava = "androidx.room:room-rxjava2:_" | ||
runtimeKtx = "androidx.lifecycle:lifecycle-runtime-ktx:_" | ||
rxAndroid = "io.reactivex.rxjava2:rxandroid:_" | ||
rxJava = "io.reactivex.rxjava2:rxjava:_" | ||
rxJava2 = "io.reactivex.rxjava2:rxjava:_" | ||
rxAndroid2 = "io.reactivex.rxjava2:rxandroid:_" | ||
rxJava3 = "io.reactivex.rxjava3:rxjava:_" | ||
rxAndroid3 = "io.reactivex.rxjava3:rxandroid:_" | ||
viewModelKtx = "androidx.lifecycle:lifecycle-viewmodel-ktx:_" | ||
viewModelCompose = "androidx.lifecycle:lifecycle-viewmodel-compose:_" | ||
viewModelSavedState = "androidx.lifecycle:lifecycle-viewmodel-savedstate:_" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
apply plugin: "com.android.library" | ||
apply plugin: "kotlin-android" | ||
apply plugin: "com.vanniktech.maven.publish" | ||
|
||
tasks.withType(KotlinCompile).all { | ||
kotlinOptions { | ||
freeCompilerArgs += [ | ||
'-opt-in=com.airbnb.mvrx.InternalMavericksApi', | ||
'-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi', | ||
'-opt-in=com.airbnb.mvrx.ExperimentalMavericksApi', | ||
] | ||
} | ||
} | ||
|
||
android { | ||
resourcePrefix "mvrx_" | ||
|
||
testOptions { | ||
unitTests { | ||
includeAndroidResources = true | ||
all { | ||
jacoco { | ||
includeNoLocationClasses = true | ||
jacoco.excludes = ['jdk.internal.*'] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
api project(':mvrx') | ||
api libs.rxJava3 | ||
|
||
implementation libs.fragment | ||
implementation libs.lifecycleCommon | ||
implementation libs.runtimeKtx | ||
|
||
testImplementation project(':mvrx-testing') | ||
testImplementation libs.junit | ||
testImplementation libs.appcompat | ||
testImplementation libs.kotlinCoroutinesTest | ||
testImplementation libs.mockito | ||
testImplementation libs.roboeletric | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
POM_NAME=Mavericks | ||
POM_ARTIFACT_ID=mavericks-rxjava2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wrong artifact id |
||
POM_PACKAGING=aar | ||
GROUP=com.airbnb.android |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<manifest package="com.airbnb.mvrx.rxjava2"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i don't think this is needed. declare the package name in the build.gradle file via the |
||
|
||
<application /> | ||
|
||
</manifest> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.airbnb.mvrx | ||
|
||
import androidx.annotation.LayoutRes | ||
import androidx.fragment.app.Fragment | ||
|
||
/** | ||
* Make your base Fragment class extend this to get MvRx functionality. | ||
* | ||
* This is necessary for the view model delegates and persistence to work correctly. | ||
*/ | ||
@Deprecated("You no longer need a base MvRxFragment. All you need to do is make your Fragment implement MavericksView.") | ||
abstract class BaseMvRxFragment(@LayoutRes contentLayoutId: Int = 0) : Fragment(contentLayoutId), MvRxView |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you planning to address this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am currently in the process of building an rxjava demo app, and as part of that, I had intended to create comprehensive documentation that includes various examples taken directly from the demo itself, However, I apologize for not including it at this time. I'll also add a guide on migration from rxjava2 to rxjava3.