kotlinforandroid
01/23/2024, 4:47 PMimport 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?ephemient
01/23/2024, 7:23 PMsuspend fun <R> ResultUseCase<Unit, R>.doWork(): R = doWork(Unit)
kotlinforandroid
01/24/2024, 1:04 PM