Generates a reducing function that maps a reducer over the entities in a container (usually an object or array). That is complicated to state, but simple if you see the implementation:
function reduceMap (fn) {
return function (state, value) {
return map(iter, state)
function iter (item, key) {
return fn(item, value, key)
}
}
}
$ npm install @f/reduce-map
var reduceMap = require('@f/reduce-map')
combineActions({
todos: handleActions({
[SET_ALL_COMPLETED]: reduceMap((todo, {completed}) => ({...todo, completed}))
})
})
fn
- A function that accepts(item, value, key)
and produces a newitem
based onvalue
.
Returns: A reducing function that maps your reducer fn
, over state
to produce a new container of type state
from each of its elements, and the value passed to reduce.
MIT