Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e4219815 authored by Nishant Dande's avatar Nishant Dande
Browse files

Return flow from usecases to handle all emit on ui

parent ddce8136
Loading
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -21,15 +21,15 @@ package foundation.e.apps.domain.login.usecase
import com.aurora.gplayapi.data.models.AuthData
import foundation.e.apps.domain.login.repository.LoginRepository
import foundation.e.apps.utils.Resource
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.single
import javax.inject.Inject

class UserLoginUseCase @Inject constructor(
    private val loginRepository: LoginRepository,
) {

    suspend fun anonymousUser(): Resource<AuthData> = flow {
    fun anonymousUser(): Flow<Resource<AuthData>> = flow {
        try {
            emit(Resource.Loading)
            val userResponse = loginRepository.anonymousUser()
@@ -37,5 +37,5 @@ class UserLoginUseCase @Inject constructor(
        } catch (e: Exception) {
            emit(Resource.Error(e.localizedMessage))
        }
    }.single()
    }
}