@twcn/redux-tools
TypeScript icon, indicating that this package has built-in type declarations

0.2.2 • Public • Published

redux-tools

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.

Readme

Keywords

Package Sidebar

Install

npm i @twcn/redux-tools

Weekly Downloads

1

Version

0.2.2

License

MIT

Unpacked Size

10.9 kB

Total Files

21

Last publish

Collaborators

  • twcn