README
GitHub license">
Redux Utilities
Common Redux utilities, including:
- Reducer factories (
containerReducer
,resetReducer
,basicApiReducer
a more). - Generic API request action type and creator factories (
asyncType
,apiRequestActions
).
Table of contents
- Installing
- Configuration
- API References
- Action Type helpers
- Action Creator helpers
- Reducer factories
- Selectors for API reducers
- Utilities
Installing
Using yarn:
$ yarn add @ackee/redux-utils
Using npm:
$ npm i -S @ackee/redux-utils
Configuration (optional)
Available options:
- Set initial reducer state globally.
- Set custom logger.
import { configure } from '@ackee/redux-utils';
// Defaults:
configure({
// Pass any object with error, warn and info methods.
logger: console,
containerReducer: reducerConfig => reducerConfig,
basicApiReducer: reducerConfig => reducerConfig,
paginationApiReducer: reducerConfig => reducerConfig,
infiniteListApiReducer: reducerConfig => reducerConfig,
});
Change reducer initial state globally
import { configure } from '@ackee/redux-utils';
configure({
// ...
basicApiReducer: ({ initialState, ...rest }) => {
return {
...rest,
initialState: {
...initialState,
// Override default error initial value:
error: null,
},
};
},
});