Converter
Handles the transformation of data between network, local storage, and domain models.
Purpose of the Converter
The Converter serves as a bridge between different data representations. The Store uses the Converter to convert data between the network, local database, and domain models.
APIs
Converter
The Converter interface has the following structure:
interface Converter<Network : Any, Local : Any, Output : Any> {
fun fromNetworkToLocal(network: Network): Local
fun fromOutputToLocal(output: Output): Local
}- Parameter
Network- Type
Any- Required
- Required
- Description
The type representing the data fetched from the remote source. For example, if fetching a list of posts, this could be
List<Post>representing the list of posts.- Parameter
Local- Type
Any- Required
- Required
- Description
The type representing the local database model representation of the item being retrieved.
- Parameter
Output- Type
Any- Required
- Required
- Description
The type representing the domain data model representation of the item being retrieved.
fromNetworkToLocal
Converts a network data model into a local data model suitable for storage.
- Parameter
network- Type
Network- Required
- Required
- Description
The network data model to be converted.
fromOutputToLocal
Converts a domain data model into a local data model suitable for storage.
- Parameter
output- Type
Output- Required
- Required
- Description
The network data model to be converted.