Advertisement
Guest User

Untitled

a guest
May 26th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. abstract class BaseUseCase<out Type, in Params> where Type : Any {
  2.  
  3. abstract suspend fun run(params: Params): Either<Failure, Type>
  4.  
  5. open operator fun invoke(
  6. scope: CoroutineScope,
  7. params: Params,
  8. onResult: (Either<Failure, Type>) -> Unit = {}
  9. ) {
  10. val backgroundJob = scope.async { run(params) }
  11. scope.launch { onResult(backgroundJob.await()) }
  12. }
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement