overdub60
overdub60

Reputation: 738

Redux: Execute two actions after one another

I ran into the following problem:

So reducerBar is dependent on a state change in reducerFoo.

What would be a clean solution to solve this problem?

Upvotes: 0

Views: 1010

Answers (2)

Ming Soon
Ming Soon

Reputation: 1018

You can use redux-saga to dispatch another action based on the results of the previous call/action.

Upvotes: 0

J. Mark Stevens
J. Mark Stevens

Reputation: 4945

Using redux-thunk it looks something like this;

export function saveSnipEdit(item) {
  return (dispatch, getState) => {
    dispatch({type: 'SaveSnipEdit', item});
    dispatch({type: 'ApiSetSnipData', data: {data: getState().snipData.allSnips}});
  };
}

Upvotes: 1

Related Questions