-
Notifications
You must be signed in to change notification settings - Fork 77
Find which items from collection have changed with lastModified #159
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
Comments
It's not possible right now. Angular-data doesn't keep a trail of hash changes, only the most recent. I supposed I could implement a change history of configurable length. Each entry could include the timestamp of the change, the resourceName and id of the changed item, and the changes themselves. You could gather from that which items have changed. What do you thinK/ |
Looks like a very useful feature IMO. Besides from being able to pinpoint changes in a big collection, you give an undo feature for free. The project I am working on is now leaving all the data for angular-data to manage, except for one resource that has a big collection and changes to individual documents must be observed by many parts of the application. This resource ATM needs a manager that dispatch events for updates in the collection, so I still keep this resource out of angular-data. I even thought about watching modifications for each individual document via lastModified but would be too much pain. |
Here's a thought: DS.defineResource('big-resource'); $scope.$watch(function () {
DS.store['big-resource'].lastModified;
}, function (hashes, prevHashes) {
var changedIds = [ ];
angular.forEach(hashes, function (timestamp, id) {
if (timestamp !== prevHashes[id]) {
changedIds.push(id);
}
});
// array of ids of items that changed
console.log(changedIds);
}, true); Edit: nevermind, this won't be sufficient |
Correct me if I am wrong, but I am guessing that it is possible that a resource gets changed (and timestamped) multiple times between one $digest and another. Consequently, $watchers will be notified once via dirty checking and will think that only the last timestamp updates are the ones counting. So if the $watches cherry pick the updated documents they will miss previous updates. If that is the case, isn't there a way to guarantee that all changes between two $digest are timestamped together? |
If the browser doesn't support The change stream seems like a better option. |
Hi,
Is it possible to get which items have been modified from one lastModified call to another?
E.g.
Thanks a lot for the project, it is making my life much easier. I have been looking around for something like this since I saw the breeze.js video.
The text was updated successfully, but these errors were encountered: