![JAR search and dependency download from the Maven repository](/logo.png)
com.sefford.kor.usecases.StandaloneUseCase.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kor-common Show documentation
Show all versions of kor-common Show documentation
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