Skip to content

Instantly share code, notes, and snippets.

@FilipeLipan
Last active March 16, 2020 13:13
Show Gist options
  • Save FilipeLipan/dcc7241c4ce73fb33881370b453ffc5c to your computer and use it in GitHub Desktop.
Save FilipeLipan/dcc7241c4ce73fb33881370b453ffc5c to your computer and use it in GitHub Desktop.
abstract class UseCase<out Type, in Params> where Type : Any {
abstract suspend fun executeOperation(params: Params): Either<Failure, Type>
suspend operator fun invoke(scope: CoroutineScope, params: Params, onResult: (Either<Failure, Type>) -> Unit = {}) = scope.launch {
val job = executeOperation(params)
withContext(Dispatchers.Main) {
onResult(job)
}
}
class None
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment