1.0.3 • Published 5 years ago

@truefit/redux-utils v1.0.3

Weekly downloads
29
License
MIT
Repository
github
Last release
5 years ago

@truefit/redux-utils

This library is a set of redux util functions. These are patterns that we have used across projects and found to be helpful.

Install

npm install @truefit/redux-utils

or

yarn add @truefit/redux-utils

Reducers

State Reducer

An HOF that allows you to express your reducer as a series of states.

ParameterTypeDescription
initialStateanythe initial value of the reducer
statesjs objectthis object has the states (action types) as the keys, and the transforms as the values
import {stateReducer} from 'truefit-redux-utils';
import {ADD_ITEM, REMOVE_ITEM} from '../actions';

export default stateReducer([], {
  [ADD_ITEM]: (state, payload) => [...state, payload],
  [REMOVE_ITEM]: (state, payload) => state.splice(state.indexOf(payload), 1),
});
1.0.3

5 years ago

1.0.2

5 years ago