npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript.Learn more »

This package has been deprecated

Author message:

This package was a temporary release. Please use the original package 'reduce-reducers' instead.

@redux-utilities/reduce-reducers

0.1.5 • Public • Published

@redux-utilities/reduce-reducers

Build Status npm Version npm Downloads Monthly

Reduce multiple reducers into a single reducer from left to right

Install

npm install @redux-utilities/reduce-reducers

Usage

import reduceReducers from '@redux-utilities/reduce-reducers';
 
const reducer = reduceReducers(
  (prev, curr) => ({ ...prev, A: prev.A + curr }),
  (prev, curr) => ({ ...prev, B: prev.B * curr })
);
 
expect(reducer({ A: 1, B: 2 }, 3)).to.deep.equal({ A: 4, B: 6 });
expect(reducer({ A: 5, B: 8 }, 13)).to.deep.equal({ A: 18, B: 104 });

FAQ

Why?

Originally created to combine multiple Redux reducers that correspond to different actions (e.g. like this). Technically works with any reducer, not just with Redux, though I don't know of any other use cases.

What is the difference between reduceReducers and combineReducers?

Take a look at this StackOverflow post: https://stackoverflow.com/questions/48104778/how-does-reducereducers-work

install

npm i @redux-utilities/reduce-reducers

Downloadsweekly downloads

0

version

0.1.5

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability