Last active
September 5, 2020 06:10
-
-
Save DenisBronx/d0331dd423ce5279729301031f5eabc0 to your computer and use it in GitHub Desktop.
Repository Pattern components
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A wrapper for handling failing requests | |
sealed class Result<T> { | |
data class Success<T>(val value: T) : Result<T>() | |
data class Failure<T>(val throwable: Throwable) : Result<T>() | |
} | |
// A DataSource for the SharedPreferences | |
interface ProductPreferences { | |
fun isFavourite(id: String?): Boolean | |
} | |
// A DataSource for the Remote DB | |
interface ProductApiService { | |
fun getProducts(): Single<Result<List<NetworkProduct>>> | |
fun getWishlist(productIds: List<String>): Single<Result<List<NetworkProduct>>> | |
} | |
// A cluster of DTOs to be mapped into a Product | |
data class DataProduct( | |
val networkProduct: NetworkProduct, | |
val isFavourite: Boolean | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment