Closed remko closed 9 years ago
Thinking about it a bit longer, I guess one solution would be to make sure that save
doesn't do simultaneous requests, and queue the last one up until the current one is finished.
You need to decide what your request strategy is:
What you are doing is a race, and it has it's benefits, if that's what you want to do.
sequential saves are easy to do, just chain the promises (or success callbacks).
parallel saves are impossible to do on PUT requests, only on PATCH, assuming you are modifying the entire model.
Other than that, I don't see a solution to this ending up in this repository, perhaps in a different one, as to keep this about core functions. Most users don't deal with these edge cases..
Suppose that I do the following:
Now suppose that the first save takes the server longer to complete than the second one. In that case, the callback to update the model with the server state will first update the model with
foo: 2
, and then withfoo: 1
, discarding the second save. Is this known? This seems to be an actual issue for me.What's the way to handle parallel PUT operations with Ampersand? Is it at all possible?