Skip to content

Instantly share code, notes, and snippets.



Created Jun 12, 2019
What would you like to do?
abstract class UseCase<out Type, in Params> where Type : Any {
abstract suspend fun run(params: Params): Either<Exception, Type>
suspend operator fun invoke(params: Params, onSuccess: (Type) -> Unit, onFailure: (Exception) -> Unit) {
val result = run(params)
coroutineScope {
launch(uiDispatcher) {
failed = { onFailure(it) },
succeeded = { onSuccess(it) }
object None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.