Closed tquetano-r7 closed 8 years ago
someAction() {
return function (dispatch) {
$.ajax({
url:"/some/url/location"
})
.success((data) => {
dispatch(data);
});
}
}
So this is easily the first thing that I tried, and it definitely dispatches ... but does nothing to prevent dispatch collision. Is there a way to use this method in a way that guarantees the one-dispatch-at-a-time requirement?
what do you mean by it does not prevent dispatch collision?
Forgive the naivete, perhaps we've been doing it wrong so far, but the update to 0.18 has us a little befuddled on how to handle dispatches on success responses from AJAX calls.
A super-rudimentary version of our 0.17.9 code:
This was all honky-dory, only dispatched when the response came back. With the new 0.18 return-based methodology, this becomes quite difficult. "return data" inside of success would return not to the correct function, and wrapping either the dispatch in the success or the entire ajax call in an async setup does not work. While the documentation has been updated in some places, I cannot seem to find an example that has been updated for the new 0.18 setup.
My question is simple ... how does one handle this circumstance, i.e. dispatching following a successful AJAX call?