Last active
January 13, 2018 19:48
-
-
Save SabagRonen/1e593170659c917a264fa91eaaf0df79 to your computer and use it in GitHub Desktop.
Clean Architecture and Kotlin Coroutines post use case
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
interface UseCase <in Request, out Response> { | |
fun handleRequest(request: Request) : Response | |
} | |
interface UseCaseResponseHandler <in Response> { | |
fun handleResponse(response: Response) | |
} | |
class UseCaseRunner <Request, Response> { | |
@Inject lateinit var runner: Runner | |
fun runUseCase( | |
useCase: UseCase<Request, Response>, | |
request: Request, | |
responseHandler: UseCaseResponseHandler<Response>) { | |
runner.run { | |
val response = useCase.handleRequest(request) | |
responseHandler.handleResponse(response) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment