Where to dispatch multiple actions in redux?

前端 未结 7 1597
终归单人心
终归单人心 2021-01-31 08:10

I am using redux with connect and redux-thunk middleware and containers.

Currently when an user perform an action, example one click on a butto

7条回答
  •  猫巷女王i
    2021-01-31 09:01

    If you have a Promise Middleware, you can use this syntax so you're able to use .then() on your dispatch(topLevelAction()):

    export const topLevelAction = () => dispatch => {
        return Promise.all([dispatch(action1()), dispatch(action2()), dispatch(action3())])
    }
    

提交回复
热议问题