Building and integrating local data sources
In this section, we will analyze how we can build local data sources and integrate them with libraries such as Room and Data Store.
Local data sources have a similar structure to remote data sources. The abstractions are provided by the layers sitting above, and the implementations are responsible for invoking methods from persistence frameworks and converting data into entities, like the following figure:
Let's assume we have the same UserEntity
defined in the previous chapters:
data class User( val id: String, val firstName: String, val lastName: String, val email: String ) { fun getFullName() = "$firstName $lastName" }
Let's make the same assumption about UserLocalDataSource
:
interface UserLocalDataSource { ...