-
Notifications
You must be signed in to change notification settings - Fork 3
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
[FIX/#300,#302] Domain 레이어 Paging3 제거 & FlowWithLifecycle 적용 #304
Conversation
…into fix/#302-paging3-domain
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.
구현 잘 되는것도 확인했나여
flow는 livedata와 다르게 초기 값을 가지고 있어서
바로 해당 초기값을 화면에 진입하고 onStart 되자마자 collect하고 있어서
LiveData에서 의도한 동작시점과 다를수도 있어서 확인이 필요합니다
@@ -33,23 +33,19 @@ class BillingManager(private val activity: Activity, private val callback: Billi | |||
val isPurchasing: StateFlow<Boolean> = _isPurchasing |
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.
여기 결제관련 BillingManager가 app에 presentation에 있어서 어색하게 느껴져서 질문한거 같은데
결제같은 경우 독립적으로 Module로(결제 모듈) 따로 만들어서 사용하면 분리가 더 잘 이루어질 것 같습니다.
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.
flow 초기값들을 대부분 UiState.Empty로 설정하고 return으로 설정해둬서 괜찮을 것 같다만, 테스트 서버가 풀려야지 확인이 가능해서 ㅠㅠ 그때 다시 확인해보겠슴둥
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.
카카오SDK 서버통신이라 구글 Billing Client 같이 우리 서버 말고 외부 서버랑 통신하는 과정들은 따로 Repository와 DataSource로 안나누어주어도 괜찮나요?
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.
좋습니다~
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 val _getDeviceTokenError = MutableStateFlow(false) | ||
val getDeviceTokenError: StateFlow<Boolean> = _getDeviceTokenError |
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.
Boolean 값을 저장하는 변수인데 조금 더 명확하게 네이밍해주는 건 어떨까요?!
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.
와 이 링크 미쳐따
@@ -78,21 +82,21 @@ class SignInActivity : BindingActivity<ActivitySignInBinding>(R.layout.activity_ | |||
// 403, 404 : 온보딩 뷰로 이동 위해 카카오 유저 정보 얻기 | |||
viewModel.getKakaoInfo() | |||
} else { | |||
// 401 : 에러 발생 | |||
// 나머지 : 에러 발생 |
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.
83번째 줄에 viewModel.getKakaoInfo()
를 호출하는 로직은 UI와 관련 없는 비즈니스 로직이라 뷰모델에서 처리하는 게 더 구조에 적합하지 않을까여?
뷰에서는 이런 로직이 보이지 않는 게 더 유지보수하기 좋을 것 같습니다!
private var userName: String = String() | ||
private var userGender: String = String() | ||
private var userEmail: String = String() | ||
private var userImage: String = String() |
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.
코드에서 ""처럼 초록색 스트링값 안봤으면 해서 추출하는 느낌으로 전환해봤서요..!
viewModel.getDeviceTokenError.flowWithLifecycle(lifecycle).onEach { error -> | ||
if (error) toast(getString(R.string.sign_in_error_connection)) | ||
}.launchIn(lifecycleScope) | ||
} | ||
|
||
// 카카오통 앱 로그인에 실패한 경우 웹 로그인 시도 | ||
private fun observeAppLoginError() { | ||
viewModel.isAppLoginAvailable.observe(this) { available -> | ||
viewModel.isAppLoginAvailable.flowWithLifecycle(lifecycle).onEach { available -> | ||
if (!available) viewModel.startKakaoLogIn(this) | ||
} | ||
}.launchIn(lifecycleScope) |
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.
코드 스타일마다 다를 것 같긴 하지만... 지금 SignIn에 상태 관련된 변수가 많아서 sealed class 하나로 합쳐서 분기 처리하면 더 깔끔할 수도 있지 않을까 하는 생각이 들었습니다!
intent.apply { | ||
val kakaoId = getLongExtra(EXTRA_KAKAO_ID, -1) | ||
val email = getStringExtra(EXTRA_EMAIL) | ||
val profileImage = getStringExtra(EXTRA_PROFILE_IMAGE) | ||
val name = getStringExtra(EXTRA_NAME) | ||
val gender = getStringExtra(EXTRA_GENDER) | ||
|
||
Intent(this@SocialSyncActivity, OnBoardingActivity::class.java).apply { | ||
putExtra(EXTRA_KAKAO_ID, kakaoId) | ||
putExtra(EXTRA_EMAIL, email) | ||
putExtra(EXTRA_PROFILE_IMAGE, profileImage) | ||
putExtra(EXTRA_NAME, name) | ||
putExtra(EXTRA_GENDER, gender) | ||
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) | ||
startActivity(this) | ||
} | ||
finish() | ||
Intent(this@SocialSyncActivity, OnBoardingActivity::class.java).apply { | ||
putExtra(EXTRA_KAKAO_ID, kakaoId) | ||
putExtra(EXTRA_EMAIL, email) | ||
putExtra(EXTRA_PROFILE_IMAGE, profileImage) | ||
putExtra(EXTRA_NAME, name) | ||
putExtra(EXTRA_GENDER, gender) | ||
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) | ||
startActivity(this) |
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.
도메인 단에 데이터 클래스 하나 만들어서 parcelableExtra로 넘겨주면 좀 더 깔끔하지 않을까 싶은데 어떤가여 🧐
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.
근데 Parcelable은 android 라이브러리라서 domain에서 선언은 해주면 안되고 UiModel 새로 만들어서 파싱하거나 해야합니다
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.
허거덩
is UiState.Failure -> { | ||
viewModel.isSubscribed = false | ||
} | ||
is UiState.Failure -> viewModel.isSubscribed = false |
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 fun initQuitBtnListener() { | ||
binding.btnProfileManageQuit.setOnSingleClickListener { | ||
AmplitudeUtils.trackEventWithProperties( | ||
"click_profile_withdrawal", | ||
JSONObject().put("withdrawal_button", "withdrawal1") | ||
"click_profile_withdrawal", JSONObject().put("withdrawal_button", "withdrawal1") |
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 fun initViewModelProvider() { | ||
kakaoViewModel = ViewModelProvider(requireActivity())[RecommendKakaoViewModel::class.java] | ||
schoolViewModel = ViewModelProvider(requireActivity())[RecommendSchoolViewModel::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.
by viewModels 안쓰고 Provider로 처리한 이유가 있나요?
위임으로 처리하면 훨씬 간결할 것 같아요!
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.
뷰모델을 한 프래그먼트에서 두개를 받아올 때에는 Provider를 활용해서 받아와야했던 것 같은데, 저 로직 구현할 때 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.
@Marchbreeze 오호 하나의 프래그먼트에서 여러 개의 뷰모델을 사용하면 안 된다고 생각했었는데 관심사 분리 측면에서는 오히려 효율적일 수 있겠네요!
with(binding) { | ||
layoutRecommendFriendsList.isVisible = true | ||
layoutRecommendNoFriendsList.isVisible = false | ||
shimmerFriendList.startShimmer() | ||
shimmerFriendList.isVisible = true | ||
rvRecommendKakao.isVisible = false | ||
} | ||
} | ||
|
||
private fun showFriendListScreen() { | ||
binding.layoutRecommendFriendsList.isVisible = true | ||
binding.layoutRecommendNoFriendsList.isVisible = false | ||
binding.shimmerFriendList.stopShimmer() | ||
binding.shimmerFriendList.visibility = View.GONE | ||
binding.rvRecommendKakao.visibility = View.VISIBLE | ||
with(binding) { | ||
layoutRecommendFriendsList.isVisible = true | ||
layoutRecommendNoFriendsList.isVisible = false | ||
shimmerFriendList.startShimmer() | ||
shimmerFriendList.isVisible = false | ||
rvRecommendKakao.isVisible = true | ||
} | ||
} | ||
|
||
private fun showNoFriendScreen() { | ||
binding.layoutRecommendFriendsList.isVisible = false | ||
binding.layoutRecommendNoFriendsList.isVisible = true | ||
binding.shimmerFriendList.stopShimmer() | ||
with(binding) { | ||
layoutRecommendFriendsList.isVisible = false | ||
layoutRecommendNoFriendsList.isVisible = true | ||
shimmerFriendList.stopShimmer() | ||
} |
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.
요런식으로 처리되는 부분이 많은 것 같은데 Boolean 인자를 받아서 값을 대입해주는 함수를 하나 만들면 조금 더 가독성이 개선될 것 같다는 생각이 들었습니다!
is UiState.Success -> { | ||
stopLoadingScreen() | ||
when (state.data?.productId) { | ||
YELLO_ONE -> { |
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.
여기 상수명도 뭐(열람권?)에 대한 상수값인지 정확하게 명시해주면 더 좋을 것 같아요!
…into fix/#302-paging3-domain
⛳️ Work Description