codelab-android-room-with-a-view icon indicating copy to clipboard operation
codelab-android-room-with-a-view copied to clipboard

(Repository & ViewModel) private LiveData mAllWords

Open squm opened this issue 4 years ago • 0 comments

Hello, I'm trying to unwrap the chain of calls from MainActivity WordRepository WordViewModel. Activity is initializing ViewModel, calls getAllWords which is defined to return mAllWords which is set in the constructor to mRepository.getAllWords which finally performs Room SQL query db.wordDao().getAlphabetizedWords

Codelab gives only this explanation:

  • Added a private member variable to hold a reference to the repository.
  • Added a getAllWords() method to return a cached list of words.
  • Implemented a constructor that creates the WordRepository.
  • In the constructor, initialized the allWords LiveData using the repository.

It is not clear what is the point of such chain of calls ?

squm avatar Jul 30 '20 12:07 squm