Last active
October 21, 2018 09:42
-
-
Save Abhityagi16/95317783acd6ac215f273580ab633e89 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
abstract class UseCase<Q : UseCase.RequestValues, P : UseCase.ResponseValue> { | |
var requestValues: Q? = null | |
var useCaseCallback: UseCaseCallback<P>? = null | |
internal fun run() { | |
executeUseCase(requestValues) | |
} | |
protected abstract fun executeUseCase(requestValues: Q?) | |
/** | |
* Data passed to a request. | |
*/ | |
interface RequestValues | |
/** | |
* Data received from a request. | |
*/ | |
interface ResponseValue | |
interface UseCaseCallback<R> { | |
fun onSuccess(response: R) | |
fun onError(t: Throwable) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment