Is it possible to return a promise / signal from the creator of the action allowed when Redux thunk successfully sent a specific action?
Consider the action creator:
function doPost(data) { return (dispatch) => { dispatch({type: POST_LOADING}); Source.doPost()
I want to call some function asynchronously in the component after calling the creator of the doPost action when Redux either sent POST_SUCCESS or POST_ERROR. One solution would be to pass the callback to the creator of the action itself, but that would make the code dirty and difficult to understand and maintain. I could also query the state of Redux during the loop, but that would be inefficient.
Ideally, the solution would be a promise that would allow / reject when certain actions are sent (in this case, POST_SUCCESS or POST_ERROR).
handlerFunction { doPost(data) closeWindow() }
The above example should be reorganized, so closeWindow () is only called when doPost () is successful.
source share