Open hazeledmands opened 10 years ago
+1, I have the same issue.
Unless the cachedItem has been modified before the $httpPromise resolves which would mean regardless of what comes back from the server, a local change has been made.
Although maybe it'd be ideal to have the resource keep track of local changes separately from the most current data from the server...
@makebbekus You're absolutely right; what do you think is the correct behavior in that circumstance? Just ignore the server version of the attribute if there's a local change to it?
@demands yeah, for now that's what this commit does https://github.com/goodeggs/angular-cached-resource/blob/6e6738886815f8b77e7637ed74da9b452b1fe1f7/src/modify_object_in_place.coffee#L9
But it does seem like there's a case where you'd be making a local change on an object and then want to "undo", and you might as well have the latest information from the server. To achieve this I think we'd need a more sophisticated way of storing resource edits separate from the last known version on the server.
Imagine you have a cached resource with some form of identifying characteristic like an
id
:Then you query CachedResource and get back something from cache right away:
But lets say the response comes back as something different:
It'd be great if BOTH of these expressions reflected the response from the server: