-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor AuthRepository by creating authState
Resolves #23
- Loading branch information
Showing
11 changed files
with
74 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 5 additions & 8 deletions
13
app/src/test/java/io/foundy/camstudy/fake/FakeAuthRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
feature/auth/domain/src/main/java/io/foundy/auth/domain/model/AuthState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package io.foundy.auth.domain.model | ||
|
||
sealed class AuthState { | ||
object NotSignedIn : AuthState() | ||
data class SignedIn(val currentUserId: String, val existsInitInfo: Boolean) : AuthState() | ||
object Error : AuthState() // TODO: Add error context message | ||
} |
8 changes: 2 additions & 6 deletions
8
feature/auth/domain/src/main/java/io/foundy/auth/domain/repository/AuthRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,11 @@ | ||
package io.foundy.auth.domain.repository | ||
|
||
import io.foundy.auth.domain.model.AuthState | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface AuthRepository { | ||
|
||
val currentUserIdStream: Flow<String?> | ||
|
||
/** | ||
* `currentUserIdStream`이 `true`인데 이 값이 `null`인 경우 서버와의 연결을 실패한 경우이다. | ||
*/ | ||
val existsInitInfo: Boolean? | ||
val stateStream: Flow<AuthState> | ||
|
||
suspend fun markAsUserInitialInfoExists(userId: String) | ||
} |
12 changes: 0 additions & 12 deletions
12
feature/auth/domain/src/main/java/io/foundy/auth/domain/usecase/ExistsInitInfoUseCase.kt
This file was deleted.
Oops, something went wrong.
7 changes: 4 additions & 3 deletions
7
.../usecase/GetCurrentUserIdStreamUseCase.kt → ...main/usecase/GetAuthStateStreamUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
package io.foundy.auth.domain.usecase | ||
|
||
import io.foundy.auth.domain.model.AuthState | ||
import io.foundy.auth.domain.repository.AuthRepository | ||
import kotlinx.coroutines.flow.Flow | ||
import javax.inject.Inject | ||
|
||
class GetCurrentUserIdStreamUseCase @Inject constructor( | ||
class GetAuthStateStreamUseCase @Inject constructor( | ||
private val authRepository: AuthRepository | ||
) { | ||
operator fun invoke(): Flow<String?> { | ||
return authRepository.currentUserIdStream | ||
operator fun invoke(): Flow<AuthState> { | ||
return authRepository.stateStream | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 3 additions & 4 deletions
7
feature/room/ui/src/test/java/io/foundy/room/ui/fake/FakeAuthRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters