4 ms·
re: an action caller needing to wait on the async action to complete: I thought that was a non-issue. If you use redux-thunk and your action creator returns a
by thom_nic 11y ago
re: an action caller needing to wait on the async action to complete: I thought that was a non-issue. If you use redux-thunk and your action creator returns a promise, the caller gets it. So while you're no longer triggering off of a redux action/store state change -- which may or may not be seen as a good thing -- you can get the promise and add a `.then()` which will fire after the async action completes.
I put together a simple example here: https://gist.github.com/thom-nic/fbedf27a5222a8490aa9028a40bf053c https://gist.github.com/thom-nic/fbedf27a5222a8490aa9028a40b...
Basically: component fires a 'delete' action, and then does page navigation when delete is successful. (Not saying this is a good idea to do it that way, just that you can do it.) Or did I miss his point?
- dyscrete 11y agoYou probably do not want to store a promise in state, it's not really serializable
- jlongster 11y agoMy post says exactly this. Read the full thing. There are other cases where you do not have a reference to the promise. (think a function being called again at some indeterminate time)
- thom_nic 11y agoOk, sorry for the misunderstanding - I'll re-read the post and see if I can understand the scenario you're describing.