redux-transduce
Last updated
Last updated
Use transducers to create Redux reducers. Conforms to the transducer protocol used by transducers.js and transducers-js, and is tested against those libraries.
transduce(xform, reducer)
transduce()
creates a reducer from a transducer and a base reducer. The transformation is applied before being sent to the base reducer.
Transducers typically operate on collections. It's possible to use transducers to transform asynchronous streams, but it requires the use of local state that persists over time. We can't do this, because Redux makes a hard assumption that the reducer is a pure function -- it must return the same result for a given state and action, every time.
For this reason, transduce()
transforms actions one at a time. That means transducers like filter()
and map()
work fine, but take()
and dedupe()
do not.