Simplified task long task execution by using Android architecture ViewModel and LiveData with RxAndroid
View the Project on GitHub VyacheslavShmakin/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)
Gradle:
implementation 'com.github.VyacheslavShmakin:rx-vmt:1.3.1'
Maven:
<dependency>
<groupId>com.github.VyacheslavShmakin</groupId>
<artifactId>rx-vmt</artifactId>
<version>1.3.1</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
// To stop running task use "stop" method
.stop()
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'io.reactivex.rxjava2:rxjava:2.2.11'
implementation 'android.arch.lifecycle:extensions:2.0.0'