react dispatch reducer multiple actions code example
Example 1: multiple reducers redux
/* Reducer Composition */
import { createStore, combineReducers } from 'redux';
const rootReducer = combineReducers({
first: firstReducer,
second: secondReducer
});
const store = createStore(rootReducer);
/* About Redux.combineReducers()
* accepts an object in which keys are associated to specific
* reducer functions, these keys are used as the name for the
* associated piece of state
*/
Example 2: dispatch two actions in redux
export const topLevelAction = () => dispatch => {
return Promise.all([dispatch(action1()), dispatch(action2()), dispatch(action3())])
}