Skip to content

Conversation

soochan8
Copy link
Collaborator

🔖 요약

  1. 불필요한 Recomposition 개선
  2. 이벤트 콜백 중앙화

🛠 작업 내용

  1. SearchActions를 통해 이벤트 콜백을 중앙화하여 처리하고, remember를 사용하여 인스턴스를 1번만 생성하여 리컴포지션이 발생했을 때 동일한 인스턴스를 재사용하도록 하였습니다.
  2. 매번 새로 생성된 콜백 람다를 하위 컴포저블에 전달하는 대신, remember로 생성된 Actions를 전달하여 처리하도록 구현하였습니다.
  3. SearchActions와 FilterActions@Stable을 명시하여, 객체를 안정적으로 인지하고 리컴포지션을 효율적으로 스킵할 수 있도록 구현하였습니다.

❓ 궁금 사항**

  1. 실무에서는 보통 어떻게 사용하는 지 궁금합니다.
  2. 실무에서는 처리하는 Event가 더 많을텐데, Event를 구분하고 SearchActions안에 FilterActions를 적용한 방식처럼 사용하는 지 궁금합니다.

- SearchActions : @stable을 적용하고 SearchScreen에서 발생하는 람다 이벤트를 관리
- SearchScreen : remember를 통해 리컴포즈 될 때 같은 콜백 참조 스킵
- state를 전부 전달 시, filter 상태가 아닌 다른 state가 변경되더라도 불필요한 리컴포지션 발생
- Filter 콜백 이벤트
@soochan8 soochan8 requested a review from f-lab-pepe September 22, 2025 10:53
@soochan8 soochan8 self-assigned this Sep 22, 2025
@soochan8 soochan8 added the refactor 코드 리팩토링 label Sep 22, 2025
- 검색어 입력, 검색결과 선택 시 검색어 포커스 clear
- 초기 데이터 지연 시, "결과 없음" 문구 노출 방지
- 기존 하위 Composable에서 관리하고 있어, 직접 상태를 넘겨줘야 했으나 공통 Effect 관리 사용으로 재사용성 향상
onEvent(SearchContract.Event.OnClickSearchProduct(productName))

fun onRemoveSearchKeyword(keyword: String) =
onEvent(SearchContract.Event.OnProductClick(keyword))
Copy link
Collaborator

Choose a reason for hiding this comment

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

onRemoveSearchKeyword 인데 OnProductClick 이벤트네요!?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

넵 해당 부분 수정하겠습니다!😂

@soochan8 soochan8 merged commit 30f656d into develop Oct 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor 코드 리팩토링

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants