Created
December 28, 2019 05:59
-
-
Save lagoJin/eac18960c508c45499890be1f0757b3e to your computer and use it in GitHub Desktop.
This file contains 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 GithubUseCase constructor( | |
private val githubRepository: GithubRepository | |
) : BaseUseCase<GithubUseCase.Params, List<DomainEntityGithub>> { | |
data class Params(val userId: String, val page: Int, val perPage: Int) | |
override fun invoke( | |
scope: CoroutineScope, | |
params: Params, | |
onSuccess: (List<DomainEntityGithub>) -> Unit, | |
onFailure: (Throwable) -> Unit | |
) { | |
scope.launch(Dispatchers.IO) { | |
githubRepository.getGithubs(params.userId, params.page, params.perPage) | |
.runCatching(onSuccess).onFailure(onFailure) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment