Merged
Conversation
This reverts commit 6671559.
|
Collaborator
Author
|
Effect.run 클로저 내부에서 Action?을 반환하는 방법으로 리팩토링을 진행했었는데, 아래의 이유로 다시 기존 방법으로 롤백하게 되었습니다. 어떠한 액션도 호출하지 않음을 nil로 반환하게 된다면 기존처럼 Action 타입에 empty case를 따로 추가해주지 않아도 된다는 장점이 존재했습니다. 그러나, 이렇게 설계하게 될 경우, 가독성 측면에서 그 쓰임새가 모호하게 느껴질 수 있다고 판단했습니다. 예시1처럼 다른 맥락에서 nil을 반환하는 상황은 reduce의 구조상 발생하지 않기 때문에, nil과 .empty를 혼동할 여지는 없지만, 프로젝트 전체를 바라보았을 때 “빈 액션을 호출하는 상황”과 “아무 액션도 호출하지 않는 상황”을 명확히 구분함으로써 가독성과 의도 전달력을 높이고자 했습니다. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



#️⃣ 연관된 이슈
📝 작업 내용
기존 ReducerKit에 구현된 코드 일부를 수정했습니다.
🎨 스크린샷
💬 추가 설명
1. Store 타입의 제네릭 표현 구조 변경
기존 Store 타입은 State, Action, R(Reducer) 세 가지 제네릭 타입 파라미터를 사용하고 있는 구조였습니다.
이를 R(Reducer) 하나의 제네릭 타입 파라미터로 단순화하고, Reducer의 연관 타입을 typealias로 정의하면서 구조를 변경하였습니다.
이에 따라 Store 타입을 간결하게 표현할 수 있어, 기존에 별도로 사용되었던 StoreOf typealias를 제거할 수 있었습니다.
이렇게 구조를 변경한 이유는, 코드가 보다 간결하게 표현되면서 가독성이 향상됐다고 느껴졌기 때문입니다.
2. Effect.run 클로저의 반환 타입을 옵셔널로 변경
기존에 Side Effect 작업 후 추가적인 Action을 호출할 필요가 없을 경우, Action에 empty 케이스를 추가하고 empty에서 아무런 동작을 수행하지 않도록 하는 방법을 사용해왔었습니다.
이는 여러 Reducer 구현체마다 empty case를 추가해줘야 한다는 점과 불필요한 Action case를 추가해줘야 한다는 단점이 보였습니다.
이를 개선하기 위해 기존 Effect.run 클로저에서 무조건적으로 Action을 반환하도록 하는 구조에서 Action? 타입으로 반환하도록, 즉 옵셔널 타입으로 반환할 수 있도록 변경하면서 새로운 Action을 호출할 필요가 없을 경우 nil을 반환할 수 있도록 개선하였습니다.