-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Duplicate API requests #6
Comments
Hmm, it's hard for me to know how to answer this without more specifics. One possible solution would be to pass a timestamp along with the payload so your store handler can determine how to deal with multiple actions: // actions.js
async getThing() {
let thing = await RESTUtils.fetchThing();
return {
thing,
timestamp: Date.now()
};
}
// store.js
handleGetThing({ thing, timestamp }) {
if (timestamp > this.latestTimestamp) {
this.latestTimestamp = timestamp;
// do something
} else {
// do something else
}
} (This isn't something I've actually tried; just an idea.) |
On second thought these kinds of race conditions are probably best handled in the actual API module by aborting duplicate requests, that way the |
@simenbrekken as long as your backend is clustered this is not so easy. @acdlite do we have any API to temporary unsubscribe from subsequent events on actionBegin and resubscribe on actionCompleted / actionFailed? Or somehow debounce events in other way. This should be at Action level. This demoes again how custom event architectures loose against Rx beauty... |
This is probably a more generic Flux question, but with getter actions how do you handle async race conditions?
E.g. an action is dispatched twice, both times the action contacts a (slow) REST API and you need to make sure that the last dispatched action supercedes the first so that a single
successHandler/failureHandler
is invoked.The text was updated successfully, but these errors were encountered: