Skip to content

Instantly share code, notes, and snippets.

@Abhityagi16
Last active October 21, 2018 09:42
Show Gist options
  • Save Abhityagi16/95317783acd6ac215f273580ab633e89 to your computer and use it in GitHub Desktop.
Save Abhityagi16/95317783acd6ac215f273580ab633e89 to your computer and use it in GitHub Desktop.
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