New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

redux-action-handler

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-action-handler

handle actions without using switch statements

latest
npmnpm
Version
0.0.3
Version published
Maintainers
1
Created
Source

redux-action-handler

Install

$ npm install redux-action-handler --save

Usage

reducer.js

import * as types from '../constants/ActionTypes';
import ActionHandler from 'redux-action-handler';

const initialState = {
  count: 0
};

const handler = new ActionHandler(initialState);

handler.addCase(types.INCREMENT, (state, action) => {
  return Object.assign({}, state, { count: state.count + 1 });
});

handler.addCase(types.DECREMENT, (state, action) => {
  return Object.assign({}, state, { count: state.count - 1 });
});

export default handler.create();

equivalent to

import * as types from '../constants/ActionTypes';
const initialState = {
  count: 0
};

export default (state = initialState, actions) => {
  switch (actions.type) {
    case: types.INCREMENT:
      return Object.assign({}, state, { count: state.count + 1 });
    case: types.DECREMENT:
      return Object.assign({}, state, { count: state.count - 1 });
    default:
      return state;
  }
}

FAQs

Package last updated on 01 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts