Closed magic0908 closed 6 years ago
看了demo,viewmodel是使用livedata的,但是个人觉得livedata远没有rxjava强大。如果在viewmodel使用rxjava,那么该如何实现类似livedata那样的动态更新数据?
LiveData 是类似观察者模式的,可以在 View 层接收到数据变化的通知来刷新 UI。 RxJava 的话,就类似 MVP 中使用的方式了,需要手动调 View 层接口。
意思是说还需要在viewmodel持有view接口的实例,然后通过回调来通知view更新?如果是这样的话就和MVP没啥区别了,也没有意义了
其实业务逻辑可以用 RxJava,UI 数据用 LiveData 就可以了
看了demo,viewmodel是使用livedata的,但是个人觉得livedata远没有rxjava强大。如果在viewmodel使用rxjava,那么该如何实现类似livedata那样的动态更新数据?