If you think that the sequence of actions in your application will look like a list or maybe more like a stream, this might make more sense.
Take this contrived example:
['apple', 'banana', 'cherry'].reduce((acc, item) => acc + item.length, 0)
The first argument is a function of the form (Int, String) => Int . Along with the initial value, you pass reduce what can be called a “reducer function”, and you get the result of processing a number of elements. So you can say that the reducer function describes what is done with each subsequent individual element to change the result. In other words, the reducer function takes the previous output and the next value, and it calculates the next result.
This is similar to what the Redux reducer does: it takes the previous state and current action and calculates the next state.
In the true style of functional programming, you can conceptually erase the value applied to the arguments and the result, and just focus on the “form” of the inputs and outputs.
In practice, Redux gearboxes are usually orthogonal, in the sense that for a given action they do not all make changes to the same properties, which makes it easy to share their responsibilities and summarize the result using combineReducers .
acjay Dec 20 '15 at 7:58 2015-12-20 07:58
source share