[Refactor] ReducerKit 리팩토링 #47
Merged
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을 반환할 수 있도록 개선하였습니다.