1.7.0 • Published 5 years ago
redux-action-helper-x v1.7.0
redux-action-helper-x
This package includes helper functions to reduce the redux boilerplate for action types and actions.
Install
npm i redux-action-helper-x
yarn add redux-action-helper-x
Helper Functions
This library offers two helper function: createRoutine and createSingleAction.
createRoutine
This helper function is mainly for REQUEST/SUCCESS/FAILURE redux action calls. It will create three action types automatically and create three action functions including the payload.
Example:
// todo.actions.js
import { createRoutine } from "redux-action-helper-x";
export const todoAddRoutine = createRoutine("todo/ADD");
// todo.reducer.js
import { todoAddRoutine } from "./todo.actions.js";
export default (state = {}, action) => {
switch (action.type) {
case todoAddRoutine.request: return {};
case todoAddRoutine.success: return {};
case todoAddRoutine.failure: return {};
default: return state;
}
}