-
Notifications
You must be signed in to change notification settings - Fork 0
4차 과제 #8
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
Conversation
- DataStore 사용해 userId 저장
- debounce 적용
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // val screen = listOf<BottomNavRoute>( | ||
| // BottomNavRoute.Home, | ||
| // BottomNavRoute.Shorts, | ||
| // BottomNavRoute.Live, | ||
| // BottomNavRoute.Search, | ||
| // BottomNavRoute.History | ||
| // ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이제 쓰지 않는 코드는 주석처리말구 지워주세용 ~
| enter = fadeIn() + slideInVertically1 { it }, | ||
| exit = fadeOut() + slideOutVertically { it } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
애니메이션까지 야무지다 ~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
진짜 깔끔하다 최고 ~~
| import kotlinx.coroutines.flow.flow | ||
| import retrofit2.Response | ||
|
|
||
| sealed class BaseState<out T> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
State까지 고려햇다고 벌써?
넌 파트장해라 ~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ErrorResponse를 따로 준비한 이유가 있을까요 ??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BaseResponse를 만들어두고 받아오는 응답의 success, code에 따라 에러와 같은 응답 처리를 해주는 것이 에러 응답을 따로 준비하는 것보다 좋아보입니다 !
| viewModelScope.launch { | ||
| authPreferences.userId.collect { | ||
| repository.patchNickname(token = it, request = request).collect { result -> | ||
| when (result) { | ||
| is BaseState.Error -> { | ||
| _effect.send(EditNicknameEffect.ShowSnackbar(result.message)) | ||
| } | ||
|
|
||
| is BaseState.Success -> { | ||
| _effect.send(EditNicknameEffect.NavigateToMy) | ||
| } | ||
| BaseState.Idle -> { | ||
| _uiState.value = BaseState.Idle | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
세미나 때 배운 enqueue가 아닌 viewModelScope를 쓰셨군요 !!
진짜 최고임 ㅠㅠ 이렇게 코루틴 기반으로 구성해주는게 훨씬 더 모던하고 안정적이랍니다.
enqueue는 콜백 기반 비동기 처리라 콜백 지옥으로 이어지기도 쉽고, 테스트나 에러 핸들링도 어려워요.
근데? viewModelScope.launch를 사용하면 코루틴 + flow 기반으로 선언적이고 간결하게 비동기 처리가 가능해지죠.
또, viewModel이 lifecycle과 함께 자동으로 취소되기 때문에 메모리 누수 방지에도 효과적이랍니다 ~~
또 ! 지금 MVI를 도입하려는 시도에 아주 자연스럽게 연결이 되고 있는 것 같아요.
정말 너무 좋은 시도와 코드 ... 너 오비해라 !

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
와 진짜 구조 예쁘게 잘 짜셨네요!!
덕분에 저도 많이 배워 갑니다 총총 ..
| @Composable | ||
| fun HomeRoute(modifier: Modifier = Modifier) { | ||
| HomeScreen( | ||
|
|
||
| ) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| HomeRoute( | ||
|
|
||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| import org.sopt.at.core.navigation.LocalNavController | ||
| import org.sopt.at.ui.theme.TvingTheme | ||
|
|
||
| // Application 클래스에 Hilt를 설정하고 애플리케이션 수준 구성요소를 사용할 수 있게 되면 Hilt는 이 주석이 있는 다른 Android 클래스에 종송 항목 제공 가능 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
공부해놓는거 짱이다
합세 아티클공유에 hilt 아티클 적어주라 ! ㅎㅎ
| ) | ||
| myNavGraph( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
너무 다닥다닥 붙어잇는거 같아요
줄바꿈해주라 !
seungjunGong
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
한주간 고생많았습니다!
전체적으로 코드를 보면서 새로운 기술들을 무리없이 잘 적용한 거 같아 인상 깊었습니다
저 또한 많은 도움 되었어요~@@!
남은 합세기간 동안도 코리 잘 부탁해요~ 파이팅bb
| fun IdTextField( | ||
| id: String, | ||
| onIdChange: (String) -> Unit, | ||
| fun BasicTextField( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
공통 컴포넌트로 뺀거 좋네용
| emit(BaseState.Error("응답이 비어 있습니다", "EMPTY")) | ||
| } | ||
| } else { | ||
| val error = Gson().fromJson(response.errorBody()?.string(), ErrorResponse::class.java) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gson 으로 error message 추출하니 깔끔하고 좋네요~
| viewModelScope.launch { | ||
| authPreferences.userId.collect { | ||
| repository.patchNickname(token = it, request = request).collect { result -> | ||
| when (result) { | ||
| is BaseState.Error -> { | ||
| _effect.send(EditNicknameEffect.ShowSnackbar(result.message)) | ||
| } | ||
|
|
||
| is BaseState.Success -> { | ||
| _effect.send(EditNicknameEffect.NavigateToMy) | ||
| } | ||
| BaseState.Idle -> { | ||
| _uiState.value = BaseState.Idle | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
와 진짜 구조 예쁘게 잘 짜셨네요!!
덕분에 저도 많이 배워 갑니다 총총 ..
| modifier = modifier | ||
| ) | ||
| } | ||
| } No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
화면 등록과 이동을 분리해주신 구조가 깔끔하네요!!
| private inline fun <reified T : Route> isSameCurrentDestination(): Boolean = | ||
| navController.currentDestination?.route == T::class.qualifiedName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이건 어디서 사용되는 건가요??
| @OptIn(FlowPreview::class) | ||
| private fun search() { | ||
| viewModelScope.launch { | ||
| queryFlow.debounce(300) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debounce 처리까지 대박이네용!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ui 상태관리 이렇게 하는거구나..
잘 작성해주어서 많은 공부 되었어요!!



📌 PR 요약
🌱 작업한 내용
🌱 PR 포인트
📸 스크린샷
📮 관련 이슈