Skip to content

redux-thunk for redux-action,follow the flux standard

Notifications You must be signed in to change notification settings

dengbupapapa/redux-thunk-payload

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

redux-thunk-payload

install

npm install redux-thunk-payload -S

use

//createStore.js
import thunkMiddleware from 'redux-thunk-payload';
let applyMiddlewares = [
    thunkMiddleware,
    ...other middleware
];
let composes = [applyMiddleware(...applyMiddlewares)];
const enhancer = compose(
    ...composes
);
let store = createStore(rootReducer, mergeState, enhancer);

//action.js
export const actiontor = createActions({
    add(payload){//If we need to do this in conjunction with other actions
        return async function (dispatch){
            dispatch(actiontor.loadingStatus(true));
            let res =  await request(payload);
            dispatch(actiontor.loadingStatus(false));
            return res
        }
    },
    loadingStatus:(payload) => payload
});

About

redux-thunk for redux-action,follow the flux standard

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published