Expose per attribute dirty status #814

Closed
tchak opened this Issue Mar 17, 2013 · 6 comments

Projects

None yet

7 participants

@tchak
Member
tchak commented Mar 17, 2013

We have almost all we need to make it happen, just need a public api.

I was thinking of something like :

App.Person = DS.Model.extend({
  name: DS.attr('string'),
 age: DS.attr('number')
});
person.set('name', 'Paul');
person.get('isDirty') // => true
person.('dirty.name') // => true
person.('dirty.age') // => false

I can work on a PR if this is desired

Owner

unsure about the api, but I think exposing the per record dirty tracking is fantastic. Especially for validations that shouldn't start validating until the attribute is dirty.

Contributor
bobbus commented Mar 18, 2013

This feature would be very useful 👍 I do not see any problem with this API proposal.

Member

Seems like a useful addition 👍

Owner
igorT commented Apr 5, 2013

This is something that is actively being worked on with all the changes to the dirtying, though for now #840 only adds a dirty counter to check how many attributes/relationships are dirty. It might be some time before this works though as there are some fairly large refactors involved.

Owner
tomdale commented May 11, 2013

@tchak Can you start a thread on Discourse to discuss this API?

@tomdale tomdale closed this May 11, 2013
Contributor

For anyone looking for the solution to this issue, it can be achieved using the DS.Model#changedAttributes method. It's use is also covered in the guide.

Note however that it is not a computed property, so the dirty status of individual attributes cannot be observed as in @tchak's proposal above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment