Last active
May 15, 2021 09:29
-
-
Save cesarferreira/3b1e6ff45da2902993a2d934d7898849 to your computer and use it in GitHub Desktop.
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
class GetFriendsUseCase( | |
private val friendsRepository: FriendsRepository | |
) : BaseUseCase<List<User>, GetFriendsUseCase.Params>() { | |
override suspend fun run(params: Params): Either<Failure, List<User>> { | |
return try { | |
val friends = friendsRepository.getFriends(params.maxNumberOfFriends) | |
Either.Right(friends) | |
} catch (exp: Exception) { | |
Either.Left(GetFriendsFailure(exp)) | |
} | |
} | |
data class Params(val maxNumberOfFriends: Int) | |
data class GetFriendsFailure(val error: Exception) : Failure.FeatureFailure(error) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment