How to dispatch an action when another becomes fulfilled with reduxjs/toolkit React and Typescript?

Viewed 502

When user is signing up. After form is submitted i want to dispatch authUser action. But i need to wait until signUp action is finished. How i can achieve that?

I've tried to dispatch one action after another but both actions are async, so they are performed simultaneously.

1 Answers

I'm not sure if this is the best way of doing this but i found working solution.

   dispatch(first)
        .unwrap()
        .then(() => dispatch(second).unwrap());
    }}
Related