Observing LiveData from ViewModel

后端 未结 6 2014
-上瘾入骨i
-上瘾入骨i 2021-01-30 05:07

I have a separate class in which I handle data fetching (specifically Firebase) and I usually return LiveData objects from it and update them asynchronously. Now I want to have

6条回答
  •  囚心锁ツ
    2021-01-30 05:42

    In this blog post by Google developer Jose Alcérreca it is recommended to use a transformation in this case (see the "LiveData in repositories" paragraph) because ViewModel shouldn't hold any reference related to View (Activity, Context etc) because it made it hard to test.

提交回复
热议问题