Skip to content

A collection of tools for quickly generating redux boilerplate code.

License

Notifications You must be signed in to change notification settings

twchn/redux-tools

Repository files navigation

npm (scoped) Build Status

A collection of tools for quickly generating redux boilerplate code.

Installation

$ npm install @twcn/redux-tools --save 

or

$ yarn add @twcn/redux-tools

Usage

import { createActionTypes, createActions, createReducer } from '@twcn/redux-tools';

const LOGIN = createActionTypes('LOGIN');

console.log(LOGIN);
// {
//   REQUEST: 'LOGIN_REQUEST',
//   SUCCESS: 'LOGIN_SUCCESS',
//   FAILURE: 'LOGIN_FAILURE'
// }

const login = createActions(LOGIN);

console.log(login);
// {
//   request: (payload) => ({ type: 'LOGIN_REQUEST', payload }),
//   success: (payload) => ({ type: 'LOGIN_SUCCESS', payload }),
//   failure: (payload) => ({ type: 'LOGIN_FAILURE', payload })
// }

const loginReducer = createReducer({ isLogin: false }, {
  [LOGIN.SUCCESS]: (state, action) => ({
    ...state,
    ...action.payload,
    isLogin: true
  })
});

Documentation

API

Contribution

You can click here to contribute your fantastic ideas.

About

A collection of tools for quickly generating redux boilerplate code.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published