Building and using remote data sources
In this section, we will look at how we can build remote data sources and how we can use them in combination with Retrofit to fetch and manipulate data from the internet.
In the previous chapters, we defined abstractions for data sources that repositories depend on to manipulate data. This was because we wanted to avoid the repositories having dependencies on the data sources and instead have the data sources depend on the repositories. For remote data sources, this looks something like the following figure:
The implementation of the remote data source has two roles. It will invoke the networking layer to fetch and manipulate data, and it will convert the data to either the domain entity or, if necessary, intermediary data required by the repository.
Let's look at the entity defined in the previous chapters:
data class User( ...