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

Commit 086312e9 authored by Nishant Dande's avatar Nishant Dande
Browse files

Modified code comment and Resource state structure

parent c9902630
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -31,12 +31,12 @@ class UserLoginUseCase @Inject constructor(
    private val loginRepository: LoginRepository,
) {

    suspend operator fun invoke(
    suspend fun anonymousUser(
        properties: Properties,
        userAgent: String
    ): Resource<AuthData> = flow {
        try {
            emit(Resource.Loading())
            emit(Resource.Loading)
            val userResponse = loginRepository.anonymousUser(
                authDataRequestBody = AnonymousAuthDataRequestBody(
                    properties = properties,
+19 −4
Original line number Diff line number Diff line
@@ -18,8 +18,23 @@

package foundation.e.apps.utils

sealed class Resource<T>(val data: T? = null, val message: String? = null) {
    class Success<T>(data: T) : Resource<T>(data)
    class Error<T>(message: String, data: T? = null) : Resource<T>(data, message)
    class Loading<T>(data: T? = null) : Resource<T>(data)
/**
 * Class represents the different states of a resource for user case layer
 */
sealed class Resource<out T> {
    /**
     * Represents a successful state of the resource with data.
     * @param data The data associated with the resource.
     */
    class Success<out T>(val data: T) : Resource<T>()
    /**
     * Represents an error state of the resource with an error message.
     * @param message The error message associated with the resource.
     */
    class Error(message: String) : Resource<Nothing>()

    /**
     * Represents a loading state of the resource.
     */
    object Loading : Resource<Nothing>()
}