Skip to content

Instantly share code, notes, and snippets.

@DenisBronx
Created October 15, 2019 13:34
Show Gist options
  • Save DenisBronx/ffa906044c45cd26e316d3f6ee8a5a7a to your computer and use it in GitHub Desktop.
Save DenisBronx/ffa906044c45cd26e316d3f6ee8a5a7a to your computer and use it in GitHub Desktop.
Dependencies for with usecase vs without usecase
// 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>()
}
// The models (simplified)
data class User(val id: String)
data class Transaction(val id: String, val amount: Float)
// The repository for the transactions
interface TransactionRepository {
fun getUserTransactions(user: User): Single<Result<List<Transaction>>>
}
// The repository for the user
interface UserRepository {
fun getUser(): Result<User>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment