ember-jsonapi-resources icon indicating copy to clipboard operation
ember-jsonapi-resources copied to clipboard

live updated dirty tracking (attrs and rels)

Open aars opened this issue 8 years ago • 3 comments

_changedAttributes and _changedRelationships are Observable arrays, to allow live dirty tracking.

aars avatar Mar 06 '17 14:03 aars

I don't really like the way this is set up, creating the Ember.A([]) only when it is first used (in attr utility and _relationAdded and _relationRemoved), but the test suite is way to fragile for me to change all that (and, I might break some intentionally fragile test setups). For example, the attr test uses this as a Resource: let Resource = Ember.Object.extend({ attributes: {}, _attributes: {} });

Of course I could add _changedAttributes etc to this "mock" resource, but I don't think thats a good way to build a test-suite. attr is not something that can or should be used without a Resource. It very much relies on the structure of Resource objects (hence the _attributes added to this Mock resource).

I'd like to discuss these changes/additions before continuing. Also, I'm going to use these changes for a bit, see if something else rears it head. For now this simply works for me.

aars avatar Mar 06 '17 14:03 aars

@aars This is great work. In working with this library originally I had been using proxy objects to track changes. Now I've been gradually moving towards handling those concerns in the resource as well and I've started to hit the same scenarios you are with this fix. When you have a moment can you fix the conflicts on this branch? I think its due to me merging in another PR where with the Ember.copy on attrs.

andrewmp1 avatar Mar 06 '17 20:03 andrewmp1

Done.

I'll add some tests when I get the chance.

aars avatar Mar 07 '17 08:03 aars