Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- abstract class BaseUseCase<out Type, in Params> where Type : Any {
- abstract suspend fun run(params: Params): Either<Failure, Type>
- open operator fun invoke(
- scope: CoroutineScope,
- params: Params,
- onResult: (Either<Failure, Type>) -> Unit = {}
- ) {
- val backgroundJob = scope.async { run(params) }
- scope.launch { onResult(backgroundJob.await()) }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement