import kotlin.coroutines.CoroutineContext
abstract class ResultUseCase<in P, out R> {
protected abstract val coroutineContext: CoroutineContext
abstract suspend fun doWork(param: P): R
suspend operator fun invoke(param: P): R = doWork(param)
}
When I have an implementation that has no parameters that it needs, I used
Unit
as the
I
generic. However, when invoking
doWork
or using the invoke operator I have to specifically pass
Unit
to it. Is there a way to not have to pass
Unit
to it? Maybe some other generic or so?
e
ephemient
01/23/2024, 7:23 PM
add an extension,
Copy code
suspend fun <R> ResultUseCase<Unit, R>.doWork(): R = doWork(Unit)