Thread
#android-architecture
    Aaron Waller

    Aaron Waller

    4 months ago
    What are the other use cases of the repository class? I know its used for getting Data from the server or cache but what else is the repository used for? I’m using the MVVM pattern and wonder where to put I/O operations like saving and writing a file. I also have a coin system in my app and I need to access that coin int from every screen in my app (settings, profile, home etc), is the Repository a good place to put it?
    a

    Andrew Neal

    4 months ago
    Have you seen the new architecture guidelines? https://developer.android.com/topic/architecture/data-layer I think reading through them, especially the data layer section will give you a better idea about how to structure things.
    K Merle

    K Merle

    4 months ago
    Saving and writing files should be treated as writing local DB or external data source. It's your data layer. Your repository should do same operations as before, and use FileService type of classes for it.
    smilecs

    smilecs

    4 months ago
    it's more of a consolidation of different sources of data, remote, cache, local etc. Your repo would or should provide easy access to data from different sources as well as make it easy to modify (if needed) those data sources.
    zhuinden

    zhuinden

    4 months ago
    Repository is just the new name for "Manager" in the Android world, so they can do literally anything and everything
    l

    Lilly

    4 months ago
    According to Martin Fowler a repository is characterized by an entity container to cache your obtained entities. Also one repository class only handles one entity, e.g. FirmwareRepository obtains only "FirmwareModel"s. There is no other use case for it