Socket
Book a DemoInstallSign in
Socket

redux0-helpers

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux0-helpers

Automate redux action creators, maps object to reducer

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

Redux helpers for action creators and reducer

Allow to use object instead of switch case statement

Simplify creating action creators

import {mapToReducer, createAction} from 'redux0-helpers';

const initState = {
  isLoading: false,
  user: undefined,
};

reducer = mapToReducer({
    [LOGIN]: state => state.set('isLoading', true),
    [LOGIN_SUCCESS]: (state, { payload }) => state
          .set('isLoading', false)
          .set('user', payload.user),
    [LOGIN_FAILS]: (state, { payload }) => state
          .set('isLoading', false)
          .set('error', payload.error),
  })(initState);

const store = createStore(currentReducer);

Server response

{
  user: {
	name: 'John' 
  }
}
const actionCreator = createAction(LOGIN_SUCCESS)(serverResponse);
store.dispatch(actionCreator());

Keywords

Redux

FAQs

Package last updated on 04 May 2017

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