Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/week compose07 #20

Open
wants to merge 2 commits into
base: develop-compose
Choose a base branch
from
Open

Conversation

OliviaYJH
Copy link
Member

πŸ“Œπ˜π˜΄π˜΄π˜Άπ˜¦π˜΄

πŸ“Žπ˜žπ˜°π˜³π˜¬ π˜‹π˜¦π˜΄π˜€π˜³π˜ͺ𝘱𝘡π˜ͺ𝘰𝘯

  • Repositoryλ₯Ό ν™œμš©ν•΄ UI와 Data둜직의 λΆ„λ¦¬ν•˜κΈ°

πŸ“·π˜šπ˜€π˜³π˜¦π˜¦π˜―π˜΄π˜©π˜°π˜΅

compose07.mp4

@OliviaYJH OliviaYJH added the πŸ“• ν•„μˆ˜ 과제 ν•„μˆ˜ 과제 label Jun 7, 2024
@OliviaYJH OliviaYJH requested a review from a team June 7, 2024 14:24
@OliviaYJH OliviaYJH self-assigned this Jun 7, 2024
@OliviaYJH OliviaYJH requested review from cacaocoffee, kez-lab, chanubc and hyoeunjoo and removed request for a team June 7, 2024 14:24
Copy link

@hyoeunjoo hyoeunjoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

composeκΉŒμ§€ μ™„λ²½ν•˜κ²Œ!! xmlμ—μ„œ 이미 λ„ˆλ¬΄ λ§Žμ€ 감탄을 ν•΄λ²„λ Έλ„€μš”..
고생 λ§ŽμœΌμ…¨μŠ΅λ‹ˆλ‹€!! μ…€ ν™§νŒ… ><

Copy link

@chanubc chanubc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ν•œ ν•™κΈ°λ™μ•ˆ λ„ˆλ¬΄ κ³ μƒλ§Žμ•˜μ–΄!!
κ³ λ§ˆμ›Œγ… γ… 

Comment on lines +8 to +17
class LoginViewModelFactory: ViewModelProvider.Factory {
override fun <T : ViewModel> create(modelClass: Class<T>): T {
if (modelClass.isAssignableFrom(LoginViewModel::class.java)) {
val repository = AuthRepositoryImpl(ServicePool.loginService)
return LoginViewModel(repository) as T
} else {
throw IllegalArgumentException("fail ${modelClass.name}")
}
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

각 viewdmodel λ³„λ‘œ factoryλ₯Ό λ”°λ‘œ λ§Œλ“€ ν•„μš”λŠ” μ—†μ–΄ λ³΄μž…λ‹ˆλ‹€! λΆˆν•„μš”ν•œ μ½”λ“œκ°€ μ¦κ°€ν•˜λŠ” 것 κ°™μ•„μš”
또 ν•˜λ‚˜μ˜ 일반적인 factory클래슀λ₯Ό 톡해 νŒ©ν† λ¦¬ λ‘œμ§μ„ 쀑앙집쀑화 ν•  수 μžˆμŠ΅λ‹ˆλ‹€. ν™•μž₯성도 더 μ’‹κ΅¬μš”
제 컴포즈 prμ—μ„œ viewmodel factoryλ₯Ό ν•˜λ‚˜λ‘œ μ‚¬μš©ν•˜λŠ” μ½”λ“œ μ°Έκ³ ν•΄λ³΄μ‹œλ©΄ 쒋을것 κ°™μ•„μš”~!!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else ifλ‚˜ when절둜 λΆ„κΈ°μ²˜λ¦¬λ§Œ ν•˜λ©΄ λ©λ‹ˆλ‹€

import com.sopt.now.compose.model.login.RequestLoginDto
import com.sopt.now.compose.model.signup.RequestSignUpDto
import com.sopt.now.compose.utils.BaseResponse
import retrofit2.Response
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ν•΄λ‹Ή repsitoryλŠ” dataλ ˆμ΄μ–΄λ‘œ κ°€λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€!
λ˜ν•œ returnνƒ€μž…μœΌλ‘œ Responseνƒ€μž…μ΄ μ•„λ‹Œ Resultνƒ€μž…μ„ μ‚¬μš©ν•΄μ£Όμ„Έμš”!

Response νƒ€μž…μ„ μ‚¬μš©ν•˜λ©΄ λ„€νŠΈμ›Œν¬ 응닡을 직접 μ²˜λ¦¬ν•΄μ•Ό ν•˜λ©°, 성곡과 μ‹€νŒ¨μ— λŒ€ν•œ λ‘œμ§μ„ λͺ…μ‹œμ μœΌλ‘œ μž‘μ„±ν•΄μ•Ό ν•©λ‹ˆλ‹€. 또 retroiftμ΄λΌλŠ” λΌμ΄λΈŒλŸ¬λ¦¬μ— 의쑴적이 단점이 μžˆμ–΄μš©

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

κΈ°νšκ²½μ„ λ–„ μ•Œλ €μ£Όμ…¨λ˜ λΆ€λΆ„μ΄λ„€μš” λ‹€μ‹œν•œλ²ˆ λ¦¬λ§ˆμΈλ“œλ„ 되고 많이 λ°°μ›Œκ°€μš”

Comment on lines +3 to 12
sealed class UiState<out T> {
data object LOADING : UiState<Nothing>()
data class SUCCESS<T>(
val data: T? = null
) : UiState()
) : UiState<T>()

data class FAILURE(
val errorMessage: String
) : UiState()
) : UiState<Nothing>()
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

goood!!
seale interface도 ν•œλ²ˆ μ‚¬μš©ν•΄λ³΄μ„Έμš”γ…Žγ…Ž

Copy link
Member

@cacaocoffee cacaocoffee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

μ‹œν—˜κΈ°κ°„μ΄λΌ 바쁠텐데도 과제 λ‹€ν•˜λŠλΌ κ³ μƒν•˜μ…¨μ–΄μš”!
많이 배우기만 ν•˜κ³  도움을 많이 λͺ»μ€¬λ˜κ²ƒ κ°™μ•„μ„œ μ•„μ‰½λ„€μš”

val state = _state.asStateFlow()

fun signUp(data: RequestSignUpDto) {
viewModelScope.launch(Dispatchers.IO) {
_state.value = UiState.LOADING
runCatching {
authService.signUp(data)
authRepository.signUp(data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runCatch ꡬ문을 Repositoryimpl λ‚΄μ—μ„œ μ²˜λ¦¬ν•  수 μžˆμ–΄μš”!
근데 μ—¬κΈ°μ„œ μ²˜λ¦¬ν•˜λŠ”κ²Œ 더 μ˜³μ€ 길인지 λͺ°λΌμ„œ
rucCatchλ₯Ό Repositoryimplμ—μ„œ μ‚¬μš©ν•  수 μžˆλ‹€ μ •λ„λ§Œ λ‚¨κ²¨λ‘˜κ²Œμš”

class AuthRepositoryImpl(
private val authService: AuthService
) : AuthRepository {
override suspend fun loginUser(data: RequestLoginDto): Response<BaseResponse<Unit>> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
override suspend fun loginUser(data: RequestLoginDto): Response<BaseResponse<Unit>> {
override suspend fun loginUser(data: RequestLoginDto): Response<BaseResponse<Unit>> =runCatching {
authService.login(data)
}

이처럼 ν•˜λ©΄ runCatch에 ν•΄λ‹Ήν•˜λŠ” λ‘œμ§μ„ 여기에 넣을 수 도 μžˆμ–΄μš”!

import com.sopt.now.compose.model.login.RequestLoginDto
import com.sopt.now.compose.model.signup.RequestSignUpDto
import com.sopt.now.compose.utils.BaseResponse
import retrofit2.Response
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

κΈ°νšκ²½μ„ λ–„ μ•Œλ €μ£Όμ…¨λ˜ λΆ€λΆ„μ΄λ„€μš” λ‹€μ‹œν•œλ²ˆ λ¦¬λ§ˆμΈλ“œλ„ 되고 많이 λ°°μ›Œκ°€μš”

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
πŸ“• ν•„μˆ˜ 과제 ν•„μˆ˜ 과제
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants