Skip to content

Instantly share code, notes, and snippets.

@pavlospt
Created May 2, 2020 10:41
Show Gist options
  • Save pavlospt/42e6c9141aa37679f1519d0ed7d28de8 to your computer and use it in GitHub Desktop.
Save pavlospt/42e6c9141aa37679f1519d0ed7d28de8 to your computer and use it in GitHub Desktop.
ResultUseCase.kt
abstract class ResultUseCase<Type, in Params> where Type : Any {
protected abstract val workDispatcher: CoroutineDispatcher
abstract suspend fun run(params: Params): Result<Type>
suspend operator fun invoke(params: Params): Result<Type> = withContext(workDispatcher) {
run(params)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment