Skip to content

Commit

Permalink
[chore] #102 필요한 주석 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
leeeha committed Aug 10, 2023
1 parent 634a1b7 commit 4244ede
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class NicknameViewModel @Inject constructor(
val isTextChanged: StateFlow<Boolean> = _isTextChanged.asStateFlow()

private val _isClickedCheckBtn = MutableStateFlow(false)
private val isClickedCheckBtn: StateFlow<Boolean> = _isClickedCheckBtn.asStateFlow()
val isClickedCheckBtn: StateFlow<Boolean> = _isClickedCheckBtn.asStateFlow()

fun getNicknameDuplicateCheck() {
viewModelScope.launch {
Expand Down Expand Up @@ -79,7 +79,6 @@ class NicknameViewModel @Inject constructor(
_isClickedCheckBtn.value = state
}

// map 쓰긴 하는데, inputUiState -> mutable 하게 바꾸자!!!!
private fun updateInputUiState(nickname: String): InputUiState {
if (nickname.isEmpty()) return InputUiState.Empty
if (!checkLength(nickname)) return InputUiState.Failure(CODE_INVALID_LENGTH)
Expand All @@ -91,7 +90,6 @@ class NicknameViewModel @Inject constructor(

// 텍스트가 바뀌었는데 중복체크를 하지 않은 경우
if (isTextChanged.value && !isClickedCheckBtn.value) {
Timber.e("isTextChanged && !isClickedCheckBtn")
return InputUiState.Failure(CODE_UNCHECKED_DUPLICATION)
}

Expand All @@ -103,6 +101,7 @@ class NicknameViewModel @Inject constructor(
private fun containsSpaceOrSpecialChar(nickname: String) =
!Regex(REGEX_PATTERN).matches(nickname)

// _nickname.map{} Flow -> MutableStateFlow 변환을 위한 확장 함수
private fun <T> Flow<T>.mutableStateIn(
initialValue: T,
scope: CoroutineScope
Expand Down

0 comments on commit 4244ede

Please sign in to comment.