All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sefford.kor.usecases.StandaloneUseCase.kt Maven / Gradle / Ivy

Go to download

Kor common platform to implement a clean architecture over your Android application

The newest version!
package com.sefford.kor.usecases

import arrow.core.Either
import com.sefford.common.interfaces.Postable
import com.sefford.kor.errors.Error
import com.sefford.kor.responses.Response
import kotlinx.coroutines.experimental.CommonPool
import kotlinx.coroutines.experimental.launch
import kotlin.coroutines.experimental.CoroutineContext

interface StandaloneUseCase

{ fun instantiate(params: P): UseCase fun execute(params: P): Either = instantiate(params).execute() fun execute(thread: CoroutineContext = CommonPool, postable: Postable, params: P) = launch(thread) { execute(params).fold({ postable.post(it) }, { postable.post(it) }) } fun execute(postable: Postable, params: P) = execute(CommonPool, postable, params) suspend fun async(params: P): Either = kotlinx.coroutines.experimental.async(CommonPool) { instantiate(params).execute() }.await() }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy