Last active
March 16, 2020 13:13
-
-
Save FilipeLipan/dcc7241c4ce73fb33881370b453ffc5c 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<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