Skip to content

Observable objects #6

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

Closed
jmdobry opened this issue Jan 6, 2014 · 1 comment
Closed

Observable objects #6

jmdobry opened this issue Jan 6, 2014 · 1 comment
Assignees
Milestone

Comments

@jmdobry
Copy link
Member

jmdobry commented Jan 6, 2014

Devs should be able to $watch two different meta properties of objects in the store to stay up-to-date with the latest version of those objects.

lastSaved - A timestamp of the last time an object was saved via an async adapter
lastModified - A timestamp of the last time any of the properties on an object changed

Examples:

$scope.$watch(function () {
  return DS.lastSaved('document', 45);
}, function (lastSavedTimestamp) {
  $scope.document = DS.get('document', 45);
});

In the above example the document on the $scope is only updated when the object is saved to the server. This is useful when you don't want the data binding in a form updating the object all over the screen when the user hasn't clicked the save button yet.

$scope.$watch(function () {
  return DS.lastModified('document', 45);
}, function (lastModifiedTimestamp) {
  $scope.document = DS.get('document', 45);
});

The above example would be more efficient than the following:

$scope.$watch(function () {
  return DS.get('document', 45);
}, ...);

because internally angular-data would use Object.observe if available, else its own digest loop that performs dirty checking just like Angular. Maybe devs should be able to throttle this digest loop as well.

This digest loop would be kicked off whenever $rootScope's digest loop runs. Maybe it can be configured to run on an interval.

jmdobry added a commit that referenced this issue Jan 7, 2014
Uses the observe-js polymer library.

#6
@ghost ghost assigned jmdobry Jan 7, 2014
@jmdobry jmdobry mentioned this issue Jan 16, 2014
5 tasks
@jmdobry
Copy link
Member Author

jmdobry commented Jan 16, 2014

This appears to be working.

@jmdobry jmdobry closed this as completed Jan 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant