GENERIC-12: Use a dedicated module to persist as much relevant data as possible. This data source should be the single source of truth driving the UI.


Description

Using one single source of data, allows for each component to only depend on the one below it. If we want to add a local database to improve the user’s experience, the component above does not need to know a local database has been added. Because the data supplied to the above layer remains the same. If however a repository was not used each component would have to maintain its own local database. Which could lead to inconsistent data, and repeated code.

Example

We created a simple application which retrieves employees from this url: http://dummy.restapiexample.com/api/v1/

We retrieve the data from the service and save it in the cache. Whenever a user requests the employee data within 5 seconds, the data is retrieved from the Repository.

Rxjava packages

Even though we have multiple sources of data, for the Presenter there only exists one source of data which is the EmployeeRepository.

Check out the Github page to view the complete repository.