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

State 와 Event 분리 #147

Merged
merged 12 commits into from
Nov 24, 2023
Merged

State 와 Event 분리 #147

merged 12 commits into from
Nov 24, 2023

Conversation

easyhooon
Copy link
Collaborator

  • ViewModel 에서 사용자의 액션을 처리하고, 이벤트를 View 에 전달하는 방식으로 변경
    -> MVVM 패턴에 적합

  • core:util 모듈 추가
    -> 공통으로 사용되는 함수 및 클래스들 중 ui 와 관련 없는, Compose 의존성이 없는 파일들을 util 로 분리

  • UiText 클래스 보완
    -> 변수가 포함된 String resource 를 핸들링 하기 위함

String Resoucr 내에 변수가 있는 경우에 대한 대응을 하기 위함
ui 모듈과 util 모듈을 분리, 다른 모듈들에서 공통으로 사용하는 ui와 관련되지 않는 함수 및 클래스를 모아둠
패키지 구조 변경-> 확장함수가 아닌 파일들은 extension 밖으로 꺼냄
Event 를 핸들링 하기 위함
뷰에서 사용자의 액션을 직접 처리하는 것은 MVVM 패턴에 위배, style check success
@easyhooon easyhooon self-assigned this Nov 12, 2023
@easyhooon easyhooon added feature tasks related to feature development refactoring Code restructure for better readability and efficiency labels Nov 12, 2023
@nAmed 를 통한 동일한 타입에 대한 식별의 경우 하드 코딩된 문자열이 식별자이므로 휴먼 에러가 발생할 수 있음
@nAmed 를 통한 식별보단 조금 더 복잡하지만 타입 안정성을 제공하고, 휴먼 에러가 발생할 가능성이 없는 Custom Qualifier(Custom Annotation Class)의 방법으로 변경
공식 문서에 의하면 modifier 의 위치는 first 'optional' parameter 임, first parameter 가 아니라
package com.nexters.bandalart.android.core.network.di

import javax.inject.Qualifier

Copy link
Collaborator

Choose a reason for hiding this comment

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

소규모 프로젝트에서는 쓸일이 없는가 싶다가도 이럴 때 한번씩 나온단 말이지 ㄷㄷ

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@nAmed Annotation -> @qualifier Annotation 으로 변경

저거 왜 commit name이 @nAmed 로 안되어있고 @nAmed 로 되어있지.. 무튼 하드 코딩으로 provider 를 분류하는게 안정성 면에서 별로인것 같다는 생각이 들어

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

아 @ 뒤에 바로 대문자를 쓰면 저렇게 변하나보네 @ Named로 써도 그러네

color: Color,
fontSize: TextUnit,
fontWeight: FontWeight,
modifier: Modifier = Modifier,
Copy link
Collaborator

Choose a reason for hiding this comment

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

요거들이 이동하게 된 이유는 무엇인가용

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

https://github.com/androidx/androidx/blob/androidx-main/compose/docs/compose-component-api-guidelines.md#modifier-parameter

내가 예전에 작업할때 해당 문서를 참고해서 modifier 를 최상단 파라미터로 올렸었는데, 문서를 내가 잘 못 이해 했던거 였음
modifier 는 first 'optional' paramter 여야 한다는 것인데, 이게 optional 의 의미가 만약에 함수를 사용할 때 해당 파라미터를 명시하지 않을 경우 default value로 선언된 값이 적용되는 파라미터들을 의미 하는데

일반적으로 Kotlin 함수의 매개변수는 default value가 없는 것들이 먼저 오고, 그 뒤에 default value가 있는 매개변수가 와야 합니다(Trailing lambda는 예외). Composable도 마찬가지로 default value가 없는 것, Modifier, default value가 있는 것 순서대로 와야 합니다.

와 같이 default value가 없는, 반드시 함수를 사용할 때 해당 파라미터를 명시해줘야하는 것들 다음에 modifier를 선언해주는 것을 권장하드라구

…state-event

# Conflicts:
#	feature/home/src/main/kotlin/com/nexters/bandalart/android/feature/home/BandalartBottomSheet.kt
필요 없는 import 제거
@easyhooon easyhooon merged commit cf1586c into develop Nov 24, 2023
1 check passed
@easyhooon easyhooon deleted the refactor/separate-state-event branch November 24, 2023 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature tasks related to feature development refactoring Code restructure for better readability and efficiency
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants