Open prabinshrestha opened 6 years ago
@prabinshrestha
Thank you so much from bottom of my heart.I will be very thankful if you provide me good sample example for it(using both),if possible?
*Yes it's recommendations from Google ( use live data in View --> ViewModel communication) and Rx Java (ViewModel ---> Businesses code (Repository Pattern) )
Again Thank you so much ;)
Its recommended since Livedata is Lifecycle-aware. Rx isn't aslong as you dont dipose it with your lifecycle.
If you forget to unsubscribe/dispose your subscription if the view is gone you will get a leak. I dont like it to mix LiveData with RxJava this is why i have a composite disposable which is disposed in onCleared() / ViewModel or onStop / View.
@mynote
The threading is ultimate easy with RxJava so I am using it, if there is any easiest option available with LiveData i will use it.Thanks
@prabinshrestha , there are several ways solving that.
Flowable.just(yourDao.updateQuery())
Flowable.create( e -> e.onNext(yourDao.updateQuery()))
Flowable.fromCallable( () -> yourDao.updateQuery())
Better use Single, since you can only receive one result for Update/Delete/Insert. No need to implement it into Room by default.