codelab-android-room-with-a-view
codelab-android-room-with-a-view copied to clipboard
(Repository & ViewModel) private LiveData mAllWords
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 ?