package com.diegocayo.organizame.domain.usecase

import com.diegocayo.organizame.domain.model.User
import com.diegocayo.organizame.domain.repository.UserRepository
import com.diegocayo.organizame.domain.utils.DispatcherProvider
import com.diegocayo.organizame.domain.utils.FlowUseCase
import kotlinx.coroutines.flow.flow
import javax.inject.Inject

class SaveUserUseCase @Inject constructor(
    private val repository: UserRepository,
    dispatcherProvider: DispatcherProvider
) : FlowUseCase<User, Unit>(dispatcherProvider) {

    override fun prepareFlow(input: User) = flow {
        repository.saveUser(input)
        emit(Unit)
    }
}