Conversation
Walkthrough루틴 등록 및 수정 시 발생하는 이벤트를 Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant ViewModel as HomeViewModel
participant UseCase as GetWriteRoutineEventFlowUseCase
participant Repo as WriteRoutineRepositoryImpl
participant DataSource
User->>Repo: registerRoutine() / editRoutine()
Repo->>DataSource: 요청 위임
DataSource-->>Repo: 결과 반환
alt 성공 시
Repo->>Repo: _writeRoutineEventFlow.emit(AddRoutine/EditRoutine)
end
ViewModel->>UseCase: getWriteRoutineEventFlowUseCase()
UseCase->>Repo: getWriteRoutineEventFlow()
Repo-->>UseCase: SharedFlow<WriteRoutineEvent>
UseCase-->>ViewModel: SharedFlow<WriteRoutineEvent>
ViewModel->>ViewModel: 이벤트 수신 시 fetchWeeklyRoutines() 호출
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15 minutes Assessment against linked issues
Assessment against linked issues: Out-of-scope changes(해당 변경사항 중 요구사항과 무관한 기능적 코드 변경은 발견되지 않았습니다.) Suggested reviewers
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
presentation/src/main/java/com/threegap/bitnagil/presentation/home/HomeViewModel.kt (1)
234-240: 에러 핸들링 추가를 고려해보세요이벤트 플로우 수집 로직은 올바르게 구현되었지만, 플로우에서 예외가 발생할 경우에 대한 처리를 추가하는 것이 좋겠습니다.
다음과 같이 에러 핸들링을 추가할 수 있습니다:
private fun observeWriteRoutineEvent() { viewModelScope.launch { - getWriteRoutineEventFlowUseCase().collect { - fetchWeeklyRoutines(container.stateFlow.value.currentWeeks) + try { + getWriteRoutineEventFlowUseCase().collect { + fetchWeeklyRoutines(container.stateFlow.value.currentWeeks) + } + } catch (e: Exception) { + Log.e("HomeViewModel", "루틴 이벤트 관찰 실패: ${e.message}") } } }data/src/main/java/com/threegap/bitnagil/data/writeroutine/repositoryImpl/WriteRoutineRepositoryImpl.kt (1)
58-59: SharedFlow 설정 검토를 고려해보세요현재 기본 설정으로 MutableSharedFlow를 사용하고 있는데, 구독자가 없을 때 이벤트가 손실될 수 있습니다. 필요에 따라 replay나 extraBufferCapacity 설정을 고려해보세요.
이벤트 손실을 방지하려면 다음과 같이 설정할 수 있습니다:
-private val _writeRoutineEventFlow = MutableSharedFlow<WriteRoutineEvent>() +private val _writeRoutineEventFlow = MutableSharedFlow<WriteRoutineEvent>( + replay = 1, + extraBufferCapacity = 64 +)다만 현재 HomeViewModel에서 즉시 구독을 시작하므로 기본 설정으로도 충분할 수 있습니다.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
data/src/main/java/com/threegap/bitnagil/data/writeroutine/repositoryImpl/WriteRoutineRepositoryImpl.kt(3 hunks)domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/model/WriteRoutineEvent.kt(1 hunks)domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/repository/WriteRoutineRepository.kt(2 hunks)domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/usecase/GetWriteRoutineEventFlowUseCase.kt(1 hunks)presentation/src/main/java/com/threegap/bitnagil/presentation/home/HomeViewModel.kt(4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (9)
domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/model/WriteRoutineEvent.kt (1)
3-6: 이벤트 모델링이 잘 설계되었습니다sealed interface를 사용한 이벤트 타입 정의가 적절하며, AddRoutine은 data object로, EditRoutine은 routineId를 포함한 data class로 구현한 것이 타입 안전성과 확장성을 보장합니다.
domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/repository/WriteRoutineRepository.kt (2)
6-7: 필요한 임포트가 올바르게 추가되었습니다WriteRoutineEvent와 Flow 관련 임포트가 적절히 추가되어 새로운 기능을 지원합니다.
25-25: 반응형 프로그래밍 패턴을 잘 적용했습니다suspend 함수로 Flow를 반환하는 설계가 코루틴과 잘 어우러지며, 기존 인터페이스 계약을 깨뜨리지 않고 확장되었습니다.
domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/usecase/GetWriteRoutineEventFlowUseCase.kt (1)
8-12: 깔끔한 유스케이스 구현입니다의존성 주입과 operator fun invoke()를 사용한 함수형 스타일이 적절하며, 도메인 계층의 추상화 역할을 잘 수행합니다.
presentation/src/main/java/com/threegap/bitnagil/presentation/home/HomeViewModel.kt (2)
47-47: 의존성 주입이 올바르게 추가되었습니다GetWriteRoutineEventFlowUseCase가 적절히 주입되어 이벤트 플로우를 관찰할 수 있습니다.
57-57: 초기화 시점이 적절합니다init 블록에서 observeWriteRoutineEvent()를 호출하여 ViewModel 생성과 동시에 이벤트 관찰을 시작합니다.
data/src/main/java/com/threegap/bitnagil/data/writeroutine/repositoryImpl/WriteRoutineRepositoryImpl.kt (3)
10-14: 필요한 임포트가 올바르게 추가되었습니다WriteRoutineEvent와 Flow 관련 임포트들이 새로운 기능 구현에 필요한 모든 요소를 포함합니다.
27-31: 성공 시에만 이벤트를 발생시키는 로직이 적절합니다also 블록을 사용하여 registerRoutine 성공 후에만 AddRoutine 이벤트를 발생시키는 것이 올바른 접근입니다.
51-55: 루틴ID를 포함한 이벤트 발생이 적절합니다editRoutine 성공 후 routineId를 포함한 EditRoutine 이벤트를 발생시켜 어떤 루틴이 수정되었는지 명확히 전달합니다.
wjdrjs00
left a comment
There was a problem hiding this comment.
등록, 수정 시 이벤트를 방출하고 수집해서 리프레시하는 방법이군요??! 야무집니다요!
현재로써는 저도 이걸 굳이 data레이어 까지 올려야 하는 필요성을 못 느껴서 리포지토리에서 처리하는 방식도 문제없을듯 합니다!!
고생하셨습니다! 어푸푸
[ PR Content ]
추천 루틴을 등록하거나 루틴을 등록/삭제했을 때 홈 화면에서 바로 리프래시하여 사용자가 갱신된 루틴 목록을 볼 수 있도록 합니다.
Related issue
Screenshot 📸
KakaoTalk_Video_2025-07-30-22-29-22.mp4
Work Description
To Reviewers 📢
Summary by CodeRabbit