Reducer
Last updated
Last updated
Reducers are pure functions that receive the current state of the store and arguments and return a new state of the store.
A pure function is a function which:
Given the same input, will always return the same output.
Produces no side effects.
describes (in this ) very well what is the payoff of pure functions.
In this example the classic switch case of disapeared. There is no more combine Reducer.
With RxStore
there is no more switch case
because we dispatch direclty a reducer to affect the state.
Reducers
are destined to be dispatched thought the store.dispatch
method. To do so, we can create .
todo.reducers.js
but we can imagine a more generic/functional way to split reducers like
common.reducers.js
and rewrigth todo.reducers.js