-
Notifications
You must be signed in to change notification settings - Fork 0
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 xml07 #19
base: develop-xml
Are you sure you want to change the base?
Feat/week xml07 #19
Conversation
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.
안녕하세요 효은님 마지막 주차 코드리뷰를 맡게된 명예 OB 서재원입니다!
코드리뷰하면서 정말 34기 YB분들은 대단하다는 생각 밖에 들지 않네요 Hilt, repository, flow까지..
공부를 하시는 중인것 같고 반영부분이 많지 않아서 저도 리뷰를 많이 달지는 않았지만 layer 분리를 하는 이유와 이점을 잘 공부해보시면 앱잼에도 도움이 많이 될 것 같습니다
솝트 세미나 완주하시느라 고생하셨습니다
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object ApiFactory { | ||
private const val BASE_URL: String = BuildConfig.AUTH_BASE_URL | ||
|
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.
ApiFactory와 모듈이 utils 폴더 아래에 있는 것은 어색하다고 느껴지네요!
엄연히 data layer의 친구들을 다루니 data 아래로 옮기는 것도 좋을 것 같습니다.
private val _state = MutableStateFlow<UiState<Unit>>(UiState.LOADING) | ||
val state get() = _state.asStateFlow() |
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.
사소하지만 변수의 타입을 명시적으로 적어주는 것이 좋습니다!
@@ -0,0 +1,12 @@ | |||
package com.sopt.now.repository |
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.
repository
역시 독립적으로 나와있을 친구가 아닌 것 같군요!
아래 안드로이드 앱 아키텍처 공식 문서를 제공 첨부해드릴테니 레이어분리를 하는 이유와 레이어 분리시 이점을 잘 알아가시면 앱잼에서도 도움이 많이 되실 것 같습니다.
https://developer.android.com/topic/architecture?hl=ko
P.S 클린 아키텍처는 완전 다른 친구입니다.
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.
감탄만 하는 코리...ㅎㅎㅜ
언니 항상 멋져요!! 이번주도 고생 많으셨습니당 ㅎㅎ
// dagger hilt | ||
implementation "com.google.dagger:hilt-android:2.51" | ||
kapt "com.google.dagger:hilt-compiler:2.51" |
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.
키야.. 믓찌다..
@HiltViewModel | ||
class SignUpViewModel @Inject constructor( | ||
private val authRepository: AuthRepository | ||
) : ViewModel() { | ||
private val _state = MutableStateFlow<UiState<Unit>>(UiState.LOADING) | ||
val state = _state.asStateFlow() | ||
val state get() = _state.asStateFlow() | ||
|
||
fun signUp(data: RequestSignUpDto) { | ||
viewModelScope.launch(Dispatchers.IO) { | ||
_state.value = UiState.LOADING | ||
runCatching { | ||
authService.signUp(data) | ||
authRepository.signupUser(data) | ||
}.onSuccess { | ||
if (it.isSuccessful) _state.value = UiState.SUCCESS(null) | ||
else { |
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.
아 진짜 멋있다..이 언니
@AndroidEntryPoint | ||
class MyPageFragment : BaseFragment<FragmentMypageBinding>(FragmentMypageBinding::bind, R.layout.fragment_mypage) { | ||
private val myPageViewModel: MyPageViewModel by viewModels() |
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.
inline fun <reified T> create(): T = | ||
retrofit.create(T::class.java) // create를 통해서 retrofit 구현체 생성 | ||
} |
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.
어 inline함수다 코인액에서 본..!! 역시 아는 만큼 보인다..
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사용 믓집니다!!
아니 왜케 잘해용
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object AuthModule { | ||
@Provides |
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.
@Singleton
컴포넌트도 붙여주세요!
싱글톤을 사용해야 해당 객체가 어플리케이션에서 생성될때 하나만 생성되고 모든 곳에서 동일한 인스턴스를 사용하게 됩니다!
이로 인해 리로스를 절약할 수 잇어요
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.
그리고 repository 인터페이서의 경우 provides보단 binds가 적합합니다!
https://developer.android.com/training/dependency-injection/hilt-android?hl=ko
https://hungseong.tistory.com/29
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단의 뷰모델이 아닌 data단의 repostiory impl에서 수행하는게 더 좋을 것 같아요!
@AndroidEntryPoint | ||
class MyPageFragment : BaseFragment<FragmentMypageBinding>(FragmentMypageBinding::bind, R.layout.fragment_mypage) { | ||
private val myPageViewModel: MyPageViewModel by viewModels() |
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.
📌𝘐𝘴𝘴𝘶𝘦𝘴
📎𝘞𝘰𝘳𝘬 𝘋𝘦𝘴𝘤𝘳𝘪𝘱𝘵𝘪𝘰𝘯
📷𝘚𝘤𝘳𝘦𝘦𝘯𝘴𝘩𝘰𝘵
Uploading xml07.mp4…