android10 / Android-CleanArchitecture-Kotlin

This is a movies sample app in Kotlin, which is part of a serie of blog posts I have written about architecting android application using different approaches.
https://fernandocejas.com/2018/05/07/architecting-android-reloaded/
4.69k stars 935 forks source link

UseCase Without return Value #94

Closed arifaizin closed 2 years ago

arifaizin commented 4 years ago

Hai.. i want to know how to make usecase without return value,

My code is like this:

class SetFavoriteTourismUseCase(private val tourismRepository: ITourismRepository) :
    UseCase<**HOWTOFILLTHIS**, Params>() {

    override suspend fun run(params: Params) = tourismRepository.setFavoriteTourism(params.tourism, params.state) //This function is void

    data class Params(val tourism: Tourism, val state: Boolean)
}

So, what should i feel in HOWTOFILLTHIS ?

Zhuinden commented 4 years ago
class SetFavoriteTourismUseCase(private val tourismRepository: ITourismRepository) {
     suspend fun setFavoriteTourism(val tourism: Tourism, val state: Boolean) {
        tourismRepository.setFavoriteTourism(tourism, state) //This function is void
     }
}

suddenly all your problems are solved

p.s. why have a repository if you have usecases tho :thinking:

ikidou commented 2 years ago

Unit