@winry/redux-tools
v0.3.1
Published
A collection of tools for quickly generating redux boilerplate code.
Downloads
8
Readme
redux-tools
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
Contribution
You can click here to contribute your fantastic ideas.