I am curious about the role of the repository in the MVVM
architecture .If you decide to add repository to your project, will this repository be responsible only for data from database or network ? The question is about SharedPreferences
or Files
, should I hold the repository responsible for that , or should I keep them in the ViewModel
.
From what I understand in MVVM I can say:
Repository should be responsible for all data that your project component ask for. Whether it's from Database or API.
Let repository grab all data from Database/API/Server/etc. Then you grab data from that repository.
You can have multiple repository if you need, like API Repository/FirebaseRepository/RoomRepository etc...
You can merge multiple data sources into one repository, but you need to handle that manually.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With