DEV Community

Discussion on: Redux: Switching to other case within the same reducer

Collapse
 
nashmeyah profile image
Nashmeyah • Edited

What about redux thunk, it allows redux to perform async dispatches. Im not sure if this will help, but i suggested this because it seems when one of your dispatches if fired off youd like it to determine something wait for a response then finish the action.

github.com/reduxjs/redux-thunk

let me know if this was any useful, I am also curious.

Collapse
 
utkal97 profile image
Utkal

Hey, thanks for the response. I have thought of this approach before, this is what I have tried (#2 in "What I tried", perhaps I didn't mention Redux-thunk in the post). But we need to access the state in action creators, which I believe is not advised. If accessing state from action creators is considered ok, I am glad to go with it. I am pretty sure this solution works, but I want to code as per the good guidelines.