Skip to content

Instantly share code, notes, and snippets.

@lagoJin
Created December 28, 2019 05:59
Show Gist options
  • Save lagoJin/eac18960c508c45499890be1f0757b3e to your computer and use it in GitHub Desktop.
Save lagoJin/eac18960c508c45499890be1f0757b3e to your computer and use it in GitHub Desktop.
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