Reducer Protocol: The Solution

Episode #202 • Aug 29, 2022 • Subscriber-Only

Let’s begin to solve a number of the problems with the Composable Architecture by introducing a reducer protocol. We will write some common conformances and operators in the new style, and even refactor a complex demo application.

The Solution
The protocol
Operator conformances
Refactoring leaf features
Refactoring combined features
Next time: composition

Unlock This Episode

Our Free plan includes 1 subscriber-only episode of your choice, plus weekly updates from our newsletter.


So, we have now seen there is still a ton of room for improvement in the library:

  • We can do a better job of providing a more natural space for housing the state, actions and logic of your features built in the Composable Architecture.
  • We can help out the compiler a bit so that it is not so strained, leading us to lose type inference, autocomplete and warnings.
  • There’s improvements we can make to readability of highly composed reducers, as well as the correctness of some of the more powerful operators in the library.
  • We definitely have to do something about the ergonomics of the environment, because right now it’s quite a pain to add new dependencies to a leaf node of an application and update every layer through to the root of the application.
  • And finally, there’s performance improvements we can make because highly modularized applications will lead to very deep call stacks.

Well, luckily for us it’s possible to solve all of these problems, and more. By putting a protocol in front of reducers, and by constructing reducers as concrete types that conform to the protocol rather than deeply nested escaping closures, we will greatly improve the experience of developing large, complex features in the library.

This episode is for subscribers only.

Subscribe to Point-Free

Access this episode, plus all past and future episodes when you become a subscriber.

See plans and pricing

Already a subscriber? Log in