Simplified task long task execution by using Android architecture ViewModel and LiveData with RxAndroid
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
gradle/wrapper
library
.gitignore
CHANGELOG.md
LICENSE.txt
README.md
_config.yml
build.gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle

README.md

Download API Licence

RxViewModelTask

Simplified task long task execution by using Android architecture ViewModel and LiveData with RxAndroid. You can simply implement Observable/Flowable/Maybe/Single/Completable objects and pass them to RxViewModelTask. It will be executed with respect to Android Lifecycle)

Download

Gradle:

implementation 'com.github.VyacheslavShmakin:rx-vmt:1.2.0'

Maven:

<dependency>
    <groupId>com.github.VyacheslavShmakin</groupId>
    <artifactId>rx-vmt</artifactId>
    <version>1.2.0</version>
    <type>aar</type>
</dependency>

Usage

// "this" - Fragment or FragmentActivity will be used as ViewModelStoreOwner and LifeCycleOwner
RxViewModelTask.create(this, "Unique String key in Fragment/FragmentActivity")
  .init(observable, observer, true)
//.init(flowable, observer, true)
//.init(single, singleObserver)
//.init(maybe, maybeObserver)
//.init(completable, completableObserver)
// You're able to use "restart" method also
  • init will execute Observable/Flowable/Maybe/Single/Completable object only once. Even if you call this multiple times the last callback method will be called.
  • restart will execute Observable/Flowable/Maybe/Single/Completable object every restart call.
  • Observable and Flowable implementation are able to collect all items when ViewModel inactive and pass them when ViewModel became active. To use this feature just enable the flag collectAll when calling init or restart method. This option is disabled by default. Please be careful by using this option to avoid UI freezes when you passing a lot of data in a short time

Imported libraries with initial version

implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
implementation 'io.reactivex.rxjava2:rxjava:2.2.3'
implementation 'android.arch.lifecycle:extensions:1.1.1'