When to use RxJava in Android and when to use LiveData from Android Architectural Components?

后端 未结 9 1376
野趣味
野趣味 2020-12-07 07:06

I am not getting the reason to use RxJava in Android and LiveData from Android Architectural Components.It would be really helpful if the usecases and differences between th

9条回答
  •  生来不讨喜
    2020-12-07 07:17

    Regarding the original question, both RxJava and LiveData complement each other really well.

    LiveData shines on ViewModel layer, with its tight integration with Android lifecycles and ViewModel. RxJava provides more capabilities in transformations (as mentioned by @Bob Dalgleish).

    Currently, we're using RxJava in data source and repository layers, and it's transformed into LiveData (using LiveDataReactiveStreams) in ViewModels (before exposing data to activities/fragments) - quite happy with this approach.

提交回复
热议问题