Redux: why are state functions called reducers?
A reducer is the component in a pipeline that reduces the pipe size from a larger to a smaller bore (inner diameter). A reducer allows for a change in pipe size to meet hydraulic flow requirements of the system, or to adapt to existing piping of a different size. So how is it related to software engineering?
The name reducer is related to the concept of a reducer in functional programming. The reducer consolidates actions into a single object representing application state.
- The reducer has the signature (state, action) => newState.
- The reducer does not mutate the state it is given, but returns a new one
If you ask me, the name Reducer is just a name, like Marty.js is the name for Marty.js and a DeLorean is the name for DeLorean. Both appear to be Flax flavors similar to Redux.